Skip to content

Commit 69b7db1

Browse files
committed
make S2 picker button not throw warning when rending in fake DOM
1 parent be7d233 commit 69b7db1

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

packages/@react-spectrum/s2/src/Picker.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
} from './Menu';
4545
import CheckmarkIcon from '../ui-icons/Checkmark';
4646
import ChevronIcon from '../ui-icons/Chevron';
47+
import {createHideableComponent} from '@react-aria/collections';
4748
import {
4849
Divider,
4950
listbox,
@@ -463,7 +464,8 @@ interface PickerButtonInnerProps<T extends object> extends PickerStyleProps, Omi
463464
buttonRef: RefObject<HTMLButtonElement | null>
464465
}
465466

466-
function PickerButton<T extends object>(props: PickerButtonInnerProps<T>) {
467+
// Needs to be hidable component or otherwise the PressResponder throws a warning when rendered in the fake DOM and tries to register
468+
const PickerButton = createHideableComponent(function PickerButton<T extends object>(props: PickerButtonInnerProps<T>) {
467469
let {
468470
isOpen,
469471
isQuiet,
@@ -555,7 +557,7 @@ function PickerButton<T extends object>(props: PickerButtonInnerProps<T>) {
555557
</Button>
556558
</PressResponder>
557559
);
558-
}
560+
});
559561

560562
export interface PickerItemProps extends Omit<ListBoxItemProps, 'children' | 'style' | 'className'>, StyleProps {
561563
children: ReactNode

packages/@react-spectrum/s2/test/Combobox.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ describe('Combobox', () => {
154154
}
155155

156156
// A bit contrived, but essentially testing a combinaiton of insertions/deletions along side some of the old entries remaining
157-
let newItems = [{name: 'Chocolate Mint'}, {name: 'Chocolate'}, {name: 'Chocolate Chip'}, {name: 'Chocolate Chip Cookie Dough'}]
157+
let newItems = [{name: 'Chocolate Mint'}, {name: 'Chocolate'}, {name: 'Chocolate Chip'}, {name: 'Chocolate Chip Cookie Dough'}];
158158
tree.rerender(<DynamicCombobox items={newItems} loadingState="idle" />);
159159

160160
options = comboboxTester.options();

packages/@react-spectrum/s2/test/Picker.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('Picker', () => {
2525
label="Test picker"
2626
items={items}
2727
isLoading={isLoading}
28-
onLoadMore={onLoadMore}>
28+
onLoadMore={onLoadMore}>
2929
{(item: any) => <PickerItem id={item.name} textValue={item.name}>{item.name}</PickerItem>}
3030
</Picker>
3131
);
@@ -46,7 +46,7 @@ describe('Picker', () => {
4646
jest.restoreAllMocks();
4747
});
4848

49-
it.skip('should only call loadMore whenever intersection is detected', async () => {
49+
it('should only call loadMore whenever intersection is detected', async () => {
5050
let onLoadMore = jest.fn();
5151
let observe = jest.fn();
5252
let observer = setupIntersectionObserverMock({
@@ -92,7 +92,7 @@ describe('Picker', () => {
9292
expect(onLoadMore).toHaveBeenCalledTimes(2);
9393
});
9494

95-
it.skip('should properly calculate the expected row index values', async () => {
95+
it('should properly calculate the expected row index values', async () => {
9696
let items = [{name: 'Chocolate'}, {name: 'Mint'}, {name: 'Chocolate Chip'}];
9797
let tree = render(<DynamicPicker items={items} />);
9898

@@ -109,7 +109,7 @@ describe('Picker', () => {
109109
expect(option).toHaveAttribute('aria-posinset', `${index + 1}`);
110110
}
111111

112-
let newItems = [...items, {name: 'Chocolate Mint'}, {name: 'Chocolate Chip Cookie Dough'}]
112+
let newItems = [...items, {name: 'Chocolate Mint'}, {name: 'Chocolate Chip Cookie Dough'}];
113113
tree.rerender(<DynamicPicker items={newItems} />);
114114

115115
options = selectTester.options();

0 commit comments

Comments
 (0)