Skip to content

fix(options): defer autosave during IME composition#1541

Open
frogGuaGuaGuaGua wants to merge 1 commit into
mainfrom
hermes/issue-1540-20260518-031640
Open

fix(options): defer autosave during IME composition#1541
frogGuaGuaGuaGua wants to merge 1 commit into
mainfrom
hermes/issue-1540-20260518-031640

Conversation

@frogGuaGuaGuaGua

Copy link
Copy Markdown
Collaborator

Summary

  • Defer autosave submissions while an input is in IME composition.
  • Save the final committed value on compositionend so CustomProvider name/description fields keep Chinese input instead of persisting pinyin.
  • Add a regression test for autosaved inputs during IME composition.

Root cause

InputFieldAutoSave submitted every change event 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=verbose
  • pnpm type-check
  • pre-push hooks: nx 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

@changeset-bot

changeset-bot Bot commented May 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: eb008d1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@read-frog/extension Patch

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

@github-actions

Copy link
Copy Markdown
Contributor

Contributor trust score

43/100 — Moderate

This score estimates contributor familiarity with mengxi-ream/read-frog using public GitHub signals. It is advisory only and does not block merges automatically.

Outcome

Score breakdown

Dimension Score Signals
Repo familiarity 24/35 commits in repo, merged PRs, reviews
Community standing 11/25 account age, followers, repo role
OSS influence 0/20 stars on owned non-fork repositories
PR track record 8/20 merge rate across resolved PRs in this repo

Signals used

  • Repo commits: 15 (author commits reachable from the repository default branch)
  • Repo PR history: merged 17, open 6, closed-unmerged 27
  • Repo reviews: 0
  • PR changed lines: 117 (+113 / -4)
  • Repo permission: write
  • Followers: 0
  • Account age: 2 months
  • Owned non-fork repos considered: max 0, total 0 (none)

Policy

  • Low-score review threshold: < 30
  • Auto-close: score < 20 and changed lines > 1000
  • Policy version: v1.1

Updated automatically when the PR changes or when a maintainer reruns the workflow.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

This PR has been inactive for 14 days and is now marked as stale.
It will be automatically closed in 30 days if no further activity occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] CustomProvider 配置界面输入中文会填入拼音,而且退格键无法删除

2 participants