Guard against double activation of buttons on Enter key - #178
Guard against double activation of buttons on Enter key#178devin-ai-integration[bot] wants to merge 1 commit into
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
🦋 Changeset detectedLatest commit: 7485f7b The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
Runtime test results (Devin)Tested the built UI in a desktop browser with an instrumented harness that logs TV mode (device-type="tv"): one activation per Enter press
Pre-fix reproduction on
|
|
@MattiasBuelens You're right — db711a8 removes the synthesized The only reason I fixed it in Your call — let me know and I'll either close this or rebase it onto #167. |
b6b8731 to
802056e
Compare
802056e to
7485f7b
Compare
|
Retargeted this at If you'd rather not carry the extra state in |
Summary
Now targets
bugfix/tv-remote(#167), which already fixes the reported TV Enter/OK flicker by dropping the synthesizedfocusedChild.click()fromUIContainer._onTvKeyDown. This adds one layer of defence on top of that, inButtonitself, so a single activation key press can never invokehandleClick()twice regardless of who turns the key press into a click (the TV container, a browser's default action for Enter, or a remote's OK button):private readonly _onClick = () => { + this._clickedDuringKeyPress = true; this.handleClick(); }; _onKeyDown: if (isActivationKey(...)) { + this._clickedDuringKeyPress = false; addEventListener('keyup', ...) } -_onKeyUp: if (isActivationKey(e.keyCode)) +_onKeyUp: if (isActivationKey(e.keyCode) && !this._clickedDuringKeyPress) this.handleClick();The flag is reset when an activation key press starts, so keyup-only activation (the normal keyboard path, and any device whose OK key does not produce a click) is unaffected — it only suppresses the keyup activation when a click for the same key press already ran.
Verified in a browser with an instrumented harness before the rebase onto #167: one Enter press in
device-type="tv"produced exactly one activation, the pre-fix double activation reproduced onmain(two activations ~19 ms apart), and mouse/Space/Enter in desktop mode each activated once. Results and screenshots are in a comment below.Link to Devin session: https://dolby.devinenterprise.com/sessions/7430bc65b800408a8e7989fa73f70548
Open in Devin Desktop: https://dolby.devinenterprise.com/desktop/session/7430bc65b800408a8e7989fa73f70548?variant=devin
Requested by: @jpestugia