Repository navigation
refactor(core): consolidate the IME composition guard into utils/ime - #4907
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsChat (@astryxdesign/core) · View in Storybook
ContextMenu (@astryxdesign/core) · View in Storybook
Dialog (@astryxdesign/core) · View in Storybook
PowerSearch (@astryxdesign/core) · View in Storybook
Tooltip (@astryxdesign/core) · View in Storybook
Typeahead (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: 2 accessibility violation(s) found — 2 serious. Chat - 1 issue(s)
PowerSearch - 1 issue(s)
Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
nynexman4464
force-pushed
the
nynexman4464/refactor/ime-guard-shared-base
branch
from
August 11, 2026 22:23
88a8d84 to
d41ca93
Compare
nynexman4464
force-pushed
the
nynexman4464/refactor/ime-guard-shared-base
branch
from
August 11, 2026 23:47
d41ca93 to
a26d166
Compare
cixzhang
approved these changes
Aug 12, 2026
Contributor
|
Looks good. We should fix build |
nynexman4464
force-pushed
the
nynexman4464/refactor/ime-guard-shared-base
branch
from
August 17, 2026 15:21
a26d166 to
1b932c8
Compare
The IME composition guard — the check that a keydown is committing or cancelling a Korean/Japanese/Chinese composition and must not be treated as a command — was implemented three different ways: a shared isImeKeyEvent predicate whose canonical definition lived inside hooks/useFocusTrap.ts, several hand-inlined isComposing/keyCode checks, and one ref-tracking variant. That scattering is why the same bug keeps being rediscovered one component at a time. Move the canonical predicate to a discoverable utils/ime.ts with the single authoritative doc comment (why the composing keydown precedes compositionend, and why the legacy keyCode fallback is still load-bearing). Name that fallback value as IME_PROCESSING_KEY_CODE rather than a bare 229. Re-export from the utils barrel and migrate the inline sites to it. isImeKeyEvent is not part of the public API (not in src/index.ts) and every consumer now imports it from utils, so no back-compat shim is needed. No behavior change — the predicate logic is identical.
nynexman4464
force-pushed
the
nynexman4464/refactor/ime-guard-shared-base
branch
from
August 17, 2026 15:44
1b932c8 to
cb94552
Compare
cixzhang
added a commit
that referenced
this pull request
Aug 18, 2026
All three conflicts are the same one: #4907 moved the IME composition guard to `utils/ime` while this branch was removing the call sites that used it. - `Dialog` and `useTooltip`: main added `isImeKeyEvent(...)` inside the per-component Escape listeners this branch deletes. The guard is not lost — `layerStack` runs the same check once, before it routes a press to any layer, so every layer on the stack is covered by one call. - `useFocusTrap`: kept this branch's `hasOpenLayer()` body and main's import path. Also drops this branch's `hooks/isImeKeyEvent.ts`, a duplicate of the predicate main now owns in `utils/ime`; `layerStack` imports from there. The `hooks` barrel keeps re-exporting it from its new home, so the public surface is unchanged. `useLayerDismissal`'s doc no longer claims the stack orders "whatever mix of layers is open": Lightbox, MobileNav and InfoTip do not register with it yet, and the doc now says so.
github-actions
Bot
deleted the
nynexman4464/refactor/ime-guard-shared-base
branch
August 18, 2026 06:11
cixzhang
added a commit
that referenced
this pull request
Aug 24, 2026
All three conflicts are the same one: #4907 moved the IME composition guard to `utils/ime` while this branch was removing the call sites that used it. - `Dialog` and `useTooltip`: main added `isImeKeyEvent(...)` inside the per-component Escape listeners this branch deletes. The guard is not lost — `layerStack` runs the same check once, before it routes a press to any layer, so every layer on the stack is covered by one call. - `useFocusTrap`: kept this branch's `hasOpenLayer()` body and main's import path. Also drops this branch's `hooks/isImeKeyEvent.ts`, a duplicate of the predicate main now owns in `utils/ime`; `layerStack` imports from there. The `hooks` barrel keeps re-exporting it from its new home, so the public surface is unchanged. `useLayerDismissal`'s doc no longer claims the stack orders "whatever mix of layers is open": Lightbox, MobileNav and InfoTip do not register with it yet, and the doc now says so.
31 of 40 tasks
This branch was successfully 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.
Why
The IME composition guard — the check that a keydown is committing/cancelling a Korean/Japanese/Chinese composition and must not be treated as a command — was implemented three different ways across the codebase: a shared
isImeKeyEventpredicate (whose canonical definition oddly lived insidehooks/useFocusTrap.ts), hand-inlinede.isComposing || e.keyCode === 229checks, and one ref-tracking variant. That scattering is why the same bug keeps getting rediscovered one component at a time (#4860, and now #4892).This is the groundwork: one canonical primitive, in a discoverable home, that everything points at — including the new lint rule stacked on top of this.
What
utils/ime.tsexportingisImeKeyEvent, with the single authoritative doc comment explaining the keydown-before-compositionend ordering and why the legacykeyCode === 229fallback is still load-bearing. Re-exported from the utils barrel.useFocusTrap.tskeeps a deprecated re-export for back-compat; the three relative importers and the three inline sites now all call the shared predicate.Risk
None intended — pure consolidation, no behavior change. The predicate is byte-for-byte the same logic; call sites are unchanged in what they guard.
Testing
utils/ime.test.ts(both signals:isComposingandkeyCode 229).tscclean;eslintclean on changed files.Design notes and the full site inventory in the follow-up issue. First of a 3-PR stack (this → editable-field fixes → lint rule).
@cixzhang