Repository navigation
[data grid] Start edit mode with text typed without a composition - #24098
Open
costajohnt wants to merge 1 commit into
Open
costajohnt wants to merge 1 commit into
costajohnt wants to merge 1 commit into
Conversation
With `imeFastEdit`, text from the emoji picker, dictation or an IME that commits directly reached the hidden editor and was lost. An `input` event with `inputType` `insertText` in view mode now starts edit mode and keeps the text. Keydown vetoes stay final, and pasted or dropped text is still ignored. Fixes mui#24063
Deploy previewBundle size
Check out the code infra dashboard for more information about this PR. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #24063
With
experimentalFeatures.imeFastEdit, typed text that arrives without a composition (emoji picker, dictation, an IME that commits a character directly) reached the hidden editor and was lost, because the keydown waits forcompositionstartandhandleChangeignored view-mode input.Now an
inputevent in view mode publishes an internalcellInputevent. Both editing hooks treat it like a composition start, with theprintableKeyDownreason, so code that already blocks that reason also blocks these inserts. The editor then waits a microtask for the edit state and applies the text through the normalsetEditCellValuepath, sovalueParserandpreProcessEditCellPropsstill run.Keeping this from reopening other holes took most of the diff:
inputType === 'insertText'starts edit mode. Paste, drop, undo and composition input keep today's behavior of being dropped, so unknown input types fail the same way master does.preventDefault, so the browser still inserted the character, which would now start edit mode.GridCellprevents the default after publishingcellKeyDownwhen a printable key was vetoed in the hidden editor, and the same happens whencanStartEditingrefuses (Shift+Space withcellSelectionandrowSelection={false}replaced the cell value otherwise).cellEditStartandrowEditStartevents can now be aChangeEvent, withparams.keyundefined. That is what changes the generated API files and proptypes.editing.mdlists the new limits.Limits worth a look
cellModesModelorrowModesModelapplied later than the microtask loses the text, and one keystroke can call the edit start callback twice. Documented rather than handled, since this is an experimental flag. Holding the text in a ref until the mode changes would remove it if you prefer that.onCellKeyDowncan't stop IME text, onlyonCellEditStartcan. Documented.preProcessEditCellProps, the start validation and the text validation now overlap, because the text skips the debounce. The race already exists for validators slower than 200 ms, so I left it.Testing
Regression tests fail on master and cover cell and row mode, vetoes, the allowlist, controlled models and non-editable cells.
imeFastEdittests pass in jsdom and in Chromium (test:browser: 174 passed inx-data-grid, 37 inx-data-grid-pro).In Chromium 156, CDP
Input.insertTextgivesinputType: 'insertText'withisComposing: false, andInput.imeSetCompositiongivesinsertCompositionTextwithisComposing: true. I have not tested a real IME, the emoji picker or dictation, andinputTypefor dictation on Safari and Firefox is unverified. If one reports something else, it is dropped as on master and the allowlist would need that value.