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

Fix correctly handle IME Input in Combobox #6239

Merged
merged 5 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ describe('useSearchAutocomplete', function () {
let stopPropagation = jest.fn();
let event = (e) => ({
...e,
nativeEvent: {
isComposing: false
},
preventDefault,
stopPropagation
});
Expand Down
3 changes: 3 additions & 0 deletions packages/@react-aria/combobox/src/useComboBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ export function useComboBox<T>(props: AriaComboBoxOptions<T>, state: ComboBoxSta

// For textfield specific keydown operations
let onKeyDown = (e: BaseEvent<KeyboardEvent<any>>) => {
if (e.nativeEvent.isComposing) {
return;
}
switch (e.key) {
case 'Enter':
case 'Tab':
Expand Down
3 changes: 3 additions & 0 deletions packages/@react-aria/combobox/test/useComboBox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ describe('useComboBox', function () {
let toggleSpy = jest.fn();
let event = (e) => ({
...e,
nativeEvent: {
isComposing: false
},
preventDefault,
stopPropagation
});
Expand Down
24 changes: 24 additions & 0 deletions packages/react-aria-components/stories/ComboBox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,27 @@ export const ComboBoxAsyncLoadingExample = () => {
</ComboBox>
);
};

export const ComboBoxImeExample = () => (
<ComboBox>
<Label style={{display: 'block'}}>IME Test</Label>
<div style={{display: 'flex'}}>
<Input />
<Button>
<span aria-hidden="true" style={{padding: '0 2px'}}>▼</span>
</Button>
</div>
<Popover placement="bottom end">
<ListBox
data-testid="combo-box-list-box"
className={styles.menu}>
<MyListBoxItem>にほんご</MyListBoxItem>
<MyListBoxItem>ニホンゴ</MyListBoxItem>
<MyListBoxItem>ニホンゴ</MyListBoxItem>
<MyListBoxItem>日本語</MyListBoxItem>
<MyListBoxItem>123</MyListBoxItem>
<MyListBoxItem>123</MyListBoxItem>
</ListBox>
</Popover>
</ComboBox>
);