Skip to content

Commit

Permalink
[datagrid] Revert "use event.type for detecting IME key press" (#14803
Browse files Browse the repository at this point in the history
)

Signed-off-by: Rom Grk <[email protected]>
Co-authored-by: Olivier Tassinari <[email protected]>
  • Loading branch information
romgrk and oliviertassinari authored Oct 2, 2024
1 parent 4148642 commit 21450de
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -958,13 +958,7 @@ describe('<DataGridPro /> - Cell editing', () => {
fireEvent.doubleClick(cell);
const input = cell.querySelector('input')!;
fireEvent.change(input, { target: { value: 'あ' } });
fireEvent.keyDown(cell, {
type: 'compositionstart',
isComposing: true,
charCode: 'あ'.charCodeAt(0),
bubbles: true,
cancelable: true,
});
fireEvent.keyDown(cell, { key: 'Enter', keyCode: 229 });
expect(listener.callCount).to.equal(0);
fireEvent.keyDown(cell, { key: 'Enter', keyCode: 13 });
expect(listener.callCount).to.equal(1);
Expand All @@ -980,22 +974,7 @@ describe('<DataGridPro /> - Cell editing', () => {
fireEvent.doubleClick(cell);
const input = cell.querySelector('input')!;
fireEvent.change(input, { target: { value: 'ありがとう' } });

fireEvent.keyDown(cell, {
type: 'compositionstart',
isComposing: true,
charCode: 'あ'.charCodeAt(0),
bubbles: true,
cancelable: true,
});
fireEvent.keyDown(cell, {
type: 'compositionupdate',
isComposing: true,
charCode: 'う'.charCodeAt(0),
bubbles: true,
cancelable: true,
});

fireEvent.keyDown(cell, { key: 'Enter', keyCode: 229 });
expect(listener.callCount).to.equal(0);
fireEvent.keyDown(cell, { key: 'Enter', keyCode: 13 });
expect(listener.callCount).to.equal(1);
Expand Down
23 changes: 2 additions & 21 deletions packages/x-data-grid-pro/src/tests/rowEditing.DataGridPro.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -931,13 +931,7 @@ describe('<DataGridPro /> - Row editing', () => {
fireEvent.doubleClick(cell);
const input = cell.querySelector('input')!;
fireEvent.change(input, { target: { value: 'あ' } });
fireEvent.keyDown(input, {
type: 'compositionstart',
isComposing: true,
charCode: 'あ'.charCodeAt(0),
bubbles: true,
cancelable: true,
});
fireEvent.keyDown(input, { key: 'Enter', keyCode: 229 });
expect(listener.callCount).to.equal(0);
fireEvent.keyDown(input, { key: 'Enter', keyCode: 13 });
expect(listener.callCount).to.equal(1);
Expand All @@ -953,20 +947,7 @@ describe('<DataGridPro /> - Row editing', () => {
fireEvent.doubleClick(cell);
const input = cell.querySelector('input')!;
fireEvent.change(input, { target: { value: 'ありがとう' } });
fireEvent.keyDown(input, {
type: 'compositionstart',
isComposing: true,
charCode: 'あ'.charCodeAt(0),
bubbles: true,
cancelable: true,
});
fireEvent.keyDown(input, {
type: 'compositionupdate',
isComposing: true,
charCode: 'う'.charCodeAt(0),
bubbles: true,
cancelable: true,
});
fireEvent.keyDown(input, { key: 'Enter', keyCode: 229 });
expect(listener.callCount).to.equal(0);
fireEvent.keyDown(input, { key: 'Enter', keyCode: 13 });
expect(listener.callCount).to.equal(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ export const useGridCellEditing = (
(params, event) => {
if (params.cellMode === GridCellModes.Edit) {
// Wait until IME is settled for Asian languages like Japanese and Chinese
if (event.type === 'compositionstart' || event.type === 'compositionupdate') {
// TODO: to replace at one point. See https://github.com/mui/material-ui/pull/39713#discussion_r1381678957.
if (event.which === 229) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ export const useGridRowEditing = (
(params, event) => {
if (params.cellMode === GridRowModes.Edit) {
// Wait until IME is settled for Asian languages like Japanese and Chinese
if (event.type === 'compositionstart' || event.type === 'compositionupdate') {
// TODO: to replace at one point. See https://github.com/mui/material-ui/pull/39713#discussion_r1381678957.
if (event.which === 229) {
return;
}

Expand Down

0 comments on commit 21450de

Please sign in to comment.