fix: Update w3c-keyname to v2.2.8 #70

Closed
nathanlesage wants to merge 1 commit from patch-1 into main
nathanlesage commented 2025-04-25 15:41:29 +02:00 (Migrated from github.com)

This PR ensures that package managers will install the most recent version of w3c-keyname.

I realized that my yarn had installed an older version of w3c-keyname on my side (2.2.6 instead of the most recent version 2.2.8). Something changed in between the two version that impacts macOS. Specifically, the older version's keyname reported, as key name, for the shortcut Cmd-Alt-∆ on macOS a j character, whereas 2.2.8 correctly reports .

I noticed that because I am currently working on a shortcut capturer to let users define custom keyboard shortcuts, and I noticed that my implementation (which also relies on keyName to be consistent between my code and CodeMirror) outputted different key names from what CodeMirror saw.

This may be even more detrimental, though, since before I installed w3c-keyname, no other package depended on it, meaning that other users probably also have 2.2.6 installed. This might lead to false positives, and I remember that it is extremely difficult to find even hard-coded editor shortcuts for macOS that work consistently.


My current mitigation is to put a resolution in my package json to enforce version 2.2.8.


A specific bug that this PR fixes for everyone that has 2.2.6 installed:

Imagine you have the keyboard shortcut Cmd-Alt-J that you wish to use on macOS. You could do it like so:

// ...
{ mac: 'Cmd-Alt-J', run: command }
// ...

However, that will never trigger when using w3c-keyname version 2.2.6, because the keyboard event reports the character instead of j. But, using the other version won't work either with version 2.2.6:

// ...
{ mac: 'Cmd-Alt-∆', run: command }
// ...

When using w3c-keyname version 2.2.8, however, the keyboard shortcut Cmd-Alt-∆ will properly trigger, as expected.

This PR ensures that package managers will install the most recent version of `w3c-keyname`. I realized that my `yarn` had installed an older version of `w3c-keyname` on my side (2.2.6 instead of the most recent version 2.2.8). Something changed in between the two version that impacts macOS. Specifically, the older version's `keyname` reported, as key name, for the shortcut `Cmd-Alt-∆` on macOS a `j` character, whereas 2.2.8 correctly reports `∆`. I noticed that because I am currently working on a shortcut capturer to let users define custom keyboard shortcuts, and I noticed that my implementation (which also relies on `keyName` to be consistent between my code and CodeMirror) outputted different key names from what CodeMirror saw. This may be even more detrimental, though, since before I installed `w3c-keyname`, no other package depended on it, meaning that other users probably also have 2.2.6 installed. This might lead to false positives, and I remember that it is extremely difficult to find even hard-coded editor shortcuts for macOS that work consistently. *** My current mitigation is to put a resolution in my package json to enforce version 2.2.8. *** A specific bug that this PR fixes for everyone that has 2.2.6 installed: Imagine you have the keyboard shortcut `Cmd-Alt-J` that you wish to use on macOS. You could do it like so: ```ts // ... { mac: 'Cmd-Alt-J', run: command } // ... ``` However, that will never trigger when using `w3c-keyname` version 2.2.6, because the keyboard event reports the character `∆` instead of `j`. But, using the other version won't work either with version 2.2.6: ```ts // ... { mac: 'Cmd-Alt-∆', run: command } // ... ``` When using `w3c-keyname` version 2.2.8, however, the keyboard shortcut `Cmd-Alt-∆` will properly trigger, as expected.
marijnh commented 2025-04-25 20:14:45 +02:00 (Migrated from github.com)

^2.2.4 covers 2.2.8. I am not going to re-release all my packages every time a dependency gets a new version. You'll just have to clear your package lock or otherwise convince your package manager to not use the old version.

`^2.2.4` covers 2.2.8. I am not going to re-release all my packages every time a dependency gets a new version. You'll just have to clear your package lock or otherwise convince your package manager to not use the old version.
nathanlesage commented 2025-04-26 00:32:48 +02:00 (Migrated from github.com)

sigh I should probably sit down and properly read the yarn manual again ... dependencies are hell. Sorry for the bother.

*sigh* I should probably sit down and properly read the yarn manual again ... dependencies are hell. Sorry for the bother.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/view!70
No description provided.