Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-select-item-user-select-1488.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@radix-ui/react-select': patch
---

Prevent text selection on Select items to avoid Firefox leaving selection mode active after closing inside a Dialog.
11 changes: 11 additions & 0 deletions packages/react/select/src/select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,14 @@ describe('clearing an optional value (#2706)', () => {
expect(emptyOptions).toHaveLength(1);
});
});

// Regression test for https://github.com/radix-ui/primitives/issues/1488
describe('given a select item', () => {
afterEach(cleanup);

it('should not allow text selection', async () => {
render(<SelectTest defaultOpen />);
const option = await waitFor(() => screen.getByRole('option', { name: 'Apple', hidden: true }));
expect(option).toHaveStyle({ userSelect: 'none' });
});
});
1 change: 1 addition & 0 deletions packages/react/select/src/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,7 @@ const SelectItem = React.forwardRef<SelectItemElement, SelectItemProps>(
data-disabled={disabled ? '' : undefined}
tabIndex={disabled ? undefined : -1}
{...itemProps}
style={{ userSelect: 'none', ...itemProps.style }}
ref={composedRefs}
onFocus={composeEventHandlers(itemProps.onFocus, () => setIsFocused(true))}
onBlur={composeEventHandlers(itemProps.onBlur, () => setIsFocused(false))}
Expand Down