fix(options): defer autosave during IME composition#1541
fix(options): defer autosave during IME composition#1541frogGuaGuaGuaGua wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: eb008d1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor trust score43/100 — Moderate This score estimates contributor familiarity with Outcome
Score breakdown
Signals used
Policy
Updated automatically when the PR changes or when a maintainer reruns the workflow. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eb008d111f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| isComposingRef.current = false | ||
| updateFieldValue(e.currentTarget.value) | ||
| onCompositionEnd?.(e) | ||
| void formForSubmit.handleSubmit() |
There was a problem hiding this comment.
Avoid submitting before the final IME input event
On Firefox/Gecko, committing IME text can fire compositionend before the non-composing input/React onChange, so e.currentTarget.value here may still be the pre-commit composition string (for example pinyin) when the user selects a candidate. Because these autosaves drive the option forms' saved config and subsequent form.reset(...), this can still persist/reset against the stale value before the actual committed character is processed, which reintroduces the IME flicker/wrong-save path for Firefox builds. Defer the submit until the final non-composing change when one follows, or otherwise avoid submitting from compositionend with the possibly stale DOM value.
Useful? React with 👍 / 👎.
|
This PR has been inactive for 14 days and is now marked as stale. |
Summary
compositionendso CustomProvider name/description fields keep Chinese input instead of persisting pinyin.Root cause
InputFieldAutoSavesubmitted everychangeevent immediately. During Chinese IME composition, browsers emit interim values such as pinyin before the composition is committed; the options form then autosaved/reset against that interim value, which can make the input appear to refresh and fight deletion/composition.Screenshots
N/A — no visual/layout change; this is input behavior covered by the regression test.
Test Plan
SKIP_FREE_API=true pnpm exec vitest run src/components/form/__tests__/input-field-auto-save.test.tsx src/entrypoints/options/pages/api-providers/provider-config-form/__tests__/provider-specific-settings-field.test.tsx --reporter=verbosepnpm type-checknx run @read-frog/extension:lint,nx run @read-frog/extension:type-check,nx run @read-frog/extension:test(141 files / 1220 tests passed)Closes #1540