Skip to content

Commit c348867

Browse files
authored
Fix correctly handle IME Input in Combobox (#6239)
Fix correctly handle IME Input in Combobox
1 parent b77d7d5 commit c348867

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

packages/@react-aria/autocomplete/test/useSearchAutocomplete.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ describe('useSearchAutocomplete', function () {
2222
let stopPropagation = jest.fn();
2323
let event = (e) => ({
2424
...e,
25+
nativeEvent: {
26+
isComposing: false
27+
},
2528
preventDefault,
2629
stopPropagation
2730
});

packages/@react-aria/combobox/src/useComboBox.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ export function useComboBox<T>(props: AriaComboBoxOptions<T>, state: ComboBoxSta
111111

112112
// For textfield specific keydown operations
113113
let onKeyDown = (e: BaseEvent<KeyboardEvent<any>>) => {
114+
if (e.nativeEvent.isComposing) {
115+
return;
116+
}
114117
switch (e.key) {
115118
case 'Enter':
116119
case 'Tab':

packages/@react-aria/combobox/test/useComboBox.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ describe('useComboBox', function () {
2424
let toggleSpy = jest.fn();
2525
let event = (e) => ({
2626
...e,
27+
nativeEvent: {
28+
isComposing: false
29+
},
2730
preventDefault,
2831
stopPropagation
2932
});

packages/react-aria-components/stories/ComboBox.stories.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,27 @@ export const ComboBoxAsyncLoadingExample = () => {
183183
</ComboBox>
184184
);
185185
};
186+
187+
export const ComboBoxImeExample = () => (
188+
<ComboBox>
189+
<Label style={{display: 'block'}}>IME Test</Label>
190+
<div style={{display: 'flex'}}>
191+
<Input />
192+
<Button>
193+
<span aria-hidden="true" style={{padding: '0 2px'}}></span>
194+
</Button>
195+
</div>
196+
<Popover placement="bottom end">
197+
<ListBox
198+
data-testid="combo-box-list-box"
199+
className={styles.menu}>
200+
<MyListBoxItem>にほんご</MyListBoxItem>
201+
<MyListBoxItem>ニホンゴ</MyListBoxItem>
202+
<MyListBoxItem>ニホンゴ</MyListBoxItem>
203+
<MyListBoxItem>日本語</MyListBoxItem>
204+
<MyListBoxItem>123</MyListBoxItem>
205+
<MyListBoxItem>123</MyListBoxItem>
206+
</ListBox>
207+
</Popover>
208+
</ComboBox>
209+
);

0 commit comments

Comments
 (0)