fix(PinInput, InputDate): resolve double input and segment issues in IME mode#6390
fix(PinInput, InputDate): resolve double input and segment issues in IME mode#6390
Conversation
📝 WalkthroughWalkthroughAdds IME composition handling to two Vue input components. InputDate.vue tracks Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/runtime/components/InputDate.vue`:
- Around line 133-148: The onCompositionEnd logic that iterates over `data` and
dispatches synthetic KeyboardEvent/InputEvent should filter to numeric digits
only to avoid creating invalid codes like "DigitA"; update the loop in the
`onCompositionEnd` handler (the block using `for (const char of data)` and
dispatching `KeyboardEvent('keydown'...)` and `InputEvent('input'...)`) to skip
any character that does not match a single digit (e.g. test with /^\d$/ or an
isDigit check) so only 0-9 characters are dispatched to the DateField segment
logic.
In `@src/runtime/components/PinInput.vue`:
- Around line 98-105: onCompositionEnd currently always re-dispatches a
synthetic input which duplicates Firefox's native post-compositionend input;
update onCompositionEnd to only dispatch the synthetic Event when the browser
does not emit a native post-compositionend input (or when we can't detect one).
Concretely, modify the onCompositionEnd handler (and related isComposing.value
logic) to either (a) skip the synthetic target.dispatchEvent(new Event('input',
{ bubbles: true })) when running in Firefox (detect via navigator.userAgent or
feature-detection for post-composition input behavior), or (b) introduce a
short-lived dedupe flag/listener so that if a native input with
isComposing=false arrives immediately after compositionend we ignore the
synthetic dispatch; ensure changes reference onCompositionEnd, isComposing, and
the target.dispatchEvent call so the duplicate final-value handling is
prevented.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0f4e3cc8-6dd8-4d97-a3d8-d205aa10e05e
📒 Files selected for processing (2)
src/runtime/components/InputDate.vuesrc/runtime/components/PinInput.vue
commit: |
|
Should we not fix these in Reka UI directly instead? 🤔 Also, we have a |


🔗 Linked issue
Resolves (None) - Fixed based on local testing for IME compatibility.
❓ Type of change
📚 Description
This PR fixes several major issues encountered by users of CJK Input Method Editors (IME):
PinInput Double Input & Firefox Compatibility:
reka-uishifts focus to the next field too early, resulting in duplicate digits.inputevents during composition and manually dispatch a cleaninputevent uponcompositionend.inputdispatch on Firefox. Firefox natively fires a post-compositionendinput event, so skipping our synthetic event prevents duplicate inputs specific to Firefox.InputDate Segment Recognition & Sanitization:
mm1).keydown(229) and simulate standard numerickeydown/inputevents when composition ends./^\d$/.test()) duringcompositionendto ensure only pure numeric digits are dispatched. This prevents invalid KeyboardEvent codes (likeDigitA) if a user accidentally types letters or symbols during IME composition.InputDate Validation/Clamping Bypass:
📝 Checklist