Skip to content

Commit 59991e2

Browse files
authored
rac dropzone fix file upload dialog (#4681)
* comments * remove visually hidden around input filetrigger
1 parent 896342a commit 59991e2

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

packages/react-aria-components/src/DropZone.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
import {AriaLabelingProps} from '@react-types/shared';
14-
import {ContextValue, Provider, RenderProps, SlotProps, useContextProps, useRenderProps, useSlot} from './utils';
14+
import {ContextValue, Provider, RenderProps, SlotProps, useContextProps, useRenderProps} from './utils';
1515
import {DropOptions, mergeProps, useClipboard, useDrop, useFocusRing, useHover, useId, VisuallyHidden} from 'react-aria';
1616
import {FileTriggerContext} from './FileTrigger';
1717
import {filterDOMProps, useLabels} from '@react-aria/utils';
@@ -40,7 +40,7 @@ export interface DropZoneRenderProps {
4040
*/
4141
isDropTarget: boolean
4242
}
43-
// note: possibly add isDisabled prop in the future
43+
4444
export interface DropZoneProps extends Omit<DropOptions, 'getDropOperationForPoint'>, RenderProps<DropZoneRenderProps>, SlotProps, AriaLabelingProps {}
4545

4646
export const DropZoneContext = createContext<ContextValue<DropZoneProps, HTMLDivElement>>(null);
@@ -51,7 +51,6 @@ function DropZone(props: DropZoneProps, ref: ForwardedRef<HTMLDivElement>) {
5151
let {dropProps, dropButtonProps, isDropTarget} = useDrop({...props, ref: buttonRef, hasDropButton: true});
5252
let {hoverProps, isHovered} = useHover({});
5353
let {focusProps, isFocused, isFocusVisible} = useFocusRing();
54-
let [fileTriggerRef] = useSlot();
5554

5655
let textId = useId();
5756
let labelProps = useLabels({'aria-labelledby': textId});
@@ -77,7 +76,7 @@ function DropZone(props: DropZoneProps, ref: ForwardedRef<HTMLDivElement>) {
7776
return (
7877
<Provider
7978
values={[
80-
[FileTriggerContext, {ref: fileTriggerRef}],
79+
[FileTriggerContext, {}],
8180
[TextContext, {id: textId, slot: 'heading'}]
8281
]}>
8382
{/* eslint-disable-next-line */}

packages/react-aria-components/src/FileTrigger.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {filterDOMProps} from '@react-aria/utils';
1616
import {Input} from './Input';
1717
import {PressResponder} from '@react-aria/interactions';
1818
import React, {createContext, ForwardedRef, forwardRef, useRef} from 'react';
19-
import {VisuallyHidden} from 'react-aria';
2019

2120
export interface FileTriggerProps extends SlotProps, DOMProps, AriaLabelingProps {
2221
/**
@@ -53,15 +52,14 @@ function FileTrigger(props: FileTriggerProps, ref: ForwardedRef<HTMLDivElement>)
5352
<PressResponder onPress={() => inputRef.current?.click()}>
5453
{children}
5554
</PressResponder>
56-
<VisuallyHidden>
57-
<Input
58-
type="file"
59-
ref={inputRef}
60-
accept={acceptedFileTypes?.toString()}
61-
onChange={(e) => onChange?.(e.target.files)}
62-
capture={defaultCamera}
63-
multiple={allowsMultiple} />
64-
</VisuallyHidden>
55+
<Input
56+
type="file"
57+
ref={inputRef}
58+
style={{display: 'none'}}
59+
accept={acceptedFileTypes?.toString()}
60+
onChange={(e) => onChange?.(e.target.files)}
61+
capture={defaultCamera}
62+
multiple={allowsMultiple} />
6563
</div>
6664
);
6765
}

0 commit comments

Comments
 (0)