Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Update Dropzone docs for Enable child pointer event #3067

Merged
merged 1 commit into from Dec 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/src/docs/others/dropzone.mdx
Expand Up @@ -80,6 +80,13 @@ To open files browser from outside of component use `openRef` prop to get functi

<Demo data={DropzoneDemos.manual} />

## Enable child pointer event

By default, Dropzone disables pointer events on its children for dragging events to work. So when we set `activateOnClick` to `false`,
clicking on any children inside Dropzone will do nothing. However, You can set style `pointerEvents: 'all'` to make children events to work:

<Demo data={DropzoneDemos.enableChildPointerEvent} />

## Mime types

To specify file types provide an object with the keys set to the [mime type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types)
Expand Down
@@ -0,0 +1,49 @@
import React, { useRef } from 'react';
import { Button } from '@mantine/core';
import { Dropzone } from '@mantine/dropzone';
import { MantineDemo } from '@mantine/ds';

const code = `
import { useRef } from 'react';
import { Button, Group } from '@mantine/core';
import { Dropzone } from '@mantine/dropzone';

function Demo() {
const openRef = useRef<() => void>(null);

return (
<>
<Dropzone
openRef={openRef}
activateOnClick={false}
styles={{ inner: { pointerEvents: 'all' } }}
>
<Button onClick={() => openRef.current()}>Select files</Button>
</Dropzone>
</>
);
}
`;

function Demo() {
const openRef = useRef<() => void>(null);

return (
<>
<Dropzone
openRef={openRef}
onDrop={() => {}}
activateOnClick={false}
styles={{ inner: { pointerEvents: 'all' } }}
>
<Button onClick={() => openRef.current()}>Select files</Button>
</Dropzone>
</>
);
}

export const enableChildPointerEvent: MantineDemo = {
type: 'demo',
component: Demo,
code,
};
1 change: 1 addition & 0 deletions src/mantine-demos/src/demos/dropzone/index.ts
Expand Up @@ -2,6 +2,7 @@ export { usage } from './Dropzone.demo.usage';
export { loading } from './Dropzone.demo.loading';
export { disabled } from './Dropzone.demo.disabled';
export { manual } from './Dropzone.demo.manual';
export { enableChildPointerEvent } from './Dropzone.demo.enableChildPointerEvent';
export { fullScreen } from './Dropzone.demo.fullScreen';
export { stylesApi } from './Dropzone.demo.stylesApi';
export { preview } from './Dropzone.demo.preview';