Skip to content

fixes eventToHotkeyString returns doubled "modifier" when "key" is a modifier - #64

Merged
theinterned merged 3 commits into
mainfrom
theinterned/double-modifier
Dec 17, 2021
Merged

fixes eventToHotkeyString returns doubled "modifier" when "key" is a modifier#64
theinterned merged 3 commits into
mainfrom
theinterned/double-modifier

Conversation

@theinterned

@theinternedtheinterned commented Dec 16, 2021

Copy link
Copy Markdown
Contributor

resolves#60

This PR fixes a bug where eventToHotkeyString was returning a "double modifier" for a key-combination where a modifier key (Control, Alt, Meta, or Shift) is also the event.key.

This PR updates eventToHotkeyString so that the resulting string still presents modifiers in a consistent order.

For more details see #60

BeforeAfter
Screen Shot 2021-12-15 at 9 50 36 AMScreen Shot 2021-12-16 at 5 58 21 PM

Screencast of the after

Screen.Recording.2021-12-16.at.5.59.41.PM.mov

Breaking change

Although the previous behaviour was likely a bug, this is a breaking change in that it changes the "hotkey string" format when a modifier key is used as the hotkey (the final element in a hotkey string sequence) for example Meta+Shift+Shift becomes Meta+Shift after this change.

Comment threadtest/test.js
Comment on lines +222 to +223
['Control+Shift', {ctrlKey: true, shiftKey: true, key: 'Shift'}],
['Control+Shift', {ctrlKey: true, shiftKey: true, key: 'Control'}]

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

These were initially failing with:

FAILED TESTS:
hotkey
eventToHotkeyString
✖ {"ctrlKey":true,"shiftKey":true,"key":"Shift"} => Control+Shift
Chrome Headless 96.0.4664.110 (Mac OS 10.15.7)
Error: Uncaught AssertionError: expected 'Control+Shift+Shift' to equal 'Control+Shift' (node_modules/chai/chai.js:250)
at Context.<anonymous> (test/test.js:232:23)
✖ {"ctrlKey":true,"shiftKey":true,"key":"Control"} => Control+Shift
Chrome Headless 96.0.4664.110 (Mac OS 10.15.7)
Error: Uncaught AssertionError: expected 'Control+Shift+Control' to equal 'Control+Shift' (node_modules/chai/chai.js:250)
at Context.<anonymous> (test/test.js:232:23)

@theinternedtheinterned added the bug Something isn't working label Dec 16, 2021
@theinternedtheinterned self-assigned this Dec 16, 2021
@theinterned

Copy link
Copy Markdown
ContributorAuthor

I wonder if you reviewers would consider this a breaking change? It is arguably as the format of the string does change.

@keithamuskeithamus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks good 👍

I do think it's a breaking change. Maybe we should rip the band-aid off with a breaking change that reworks the format?

@theinternedtheinterned mentioned this pull request Dec 17, 2021
3 tasks
@theinterned
theinterned merged commit 70208b4 into mainDec 17, 2021
@theinterned
theinterned deleted the theinterned/double-modifier branch December 17, 2021 18:05
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugSomething isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eventToHotkeyString returns doubled "modifier" when "key" is a modifier

2 participants

@theinterned@keithamus