fix(web): Fix null error with legacy keyboards#10141
Conversation
User Test ResultsTest specification and instructions
Test Artifacts
|
| K_NUMLOCK: false, | ||
| K_SCROLL: false | ||
| })); | ||
| Lkc.Lcode = KeyMapping._USKeyCodeToCharCode(keyboard.constructNullKeyEvent(null, null)); |
There was a problem hiding this comment.
Can you explain the reason for this change? I don't understand it
There was a problem hiding this comment.
Hmm... it is worth noting that the original line doesn't reference an actual key. Personally, when running a trace on what's going on, this block is extremely illuminating:
keyman/common/web/keyboard-processor/src/keyboards/keyboard.ts
Lines 471 to 473 in 4c7b799
Note that we're within the constructBaseKeyEvent method (for this comment). L473 above is relying upon the results of said method. This is an obvious problem.
Since this hasn't exactly been a section of code I've actually dived into much, perhaps a comparison against stable-10.0 is in order. I've moved the code a few times since then, so I'll highlight the corresponding section to move things along:
keyman/web/source/kmwdomevents.ts
Lines 722 to 734 in f16872a
(Note that this is constructing the event in full from nothing, rather than the partial construction intended for constructBaseKeyEvent.)
So... KMW 1.0 used different key-code values, and we just need to map the key code we use now to the one that was used then. It's not even like we're replacing the other key-event values... just .Lcode here and .LisVirtualKey on the next line.
Something far closer to the original would likely be best here. I'm confident that we don't even need to create an intermediary event object... and that'll let us bypass the need for the other change - the optional-based null guard.
There was a problem hiding this comment.
this block is extremely illuminating
Not to me! Perhaps you could explain it more clearly for me?
There was a problem hiding this comment.
Note that we're within the constructBaseKeyEvent method (for this comment). L473 above is relying upon the results of said method. This is an obvious problem.
In other words, we have an impossible-to-meet precondition here. We're within a method that must complete to satisfy the precondition of a method it's calling.
There was a problem hiding this comment.
Fortunately, we can simplify things greatly here... that's what the rest of the analysis is about.
| K_NUMLOCK: false, | ||
| K_SCROLL: false | ||
| })); | ||
| Lkc.Lcode = KeyMapping._USKeyCodeToCharCode(keyboard.constructNullKeyEvent(null, null)); |
There was a problem hiding this comment.
Hmm... it is worth noting that the original line doesn't reference an actual key. Personally, when running a trace on what's going on, this block is extremely illuminating:
keyman/common/web/keyboard-processor/src/keyboards/keyboard.ts
Lines 471 to 473 in 4c7b799
Note that we're within the constructBaseKeyEvent method (for this comment). L473 above is relying upon the results of said method. This is an obvious problem.
Since this hasn't exactly been a section of code I've actually dived into much, perhaps a comparison against stable-10.0 is in order. I've moved the code a few times since then, so I'll highlight the corresponding section to move things along:
keyman/web/source/kmwdomevents.ts
Lines 722 to 734 in f16872a
(Note that this is constructing the event in full from nothing, rather than the partial construction intended for constructBaseKeyEvent.)
So... KMW 1.0 used different key-code values, and we just need to map the key code we use now to the one that was used then. It's not even like we're replacing the other key-event values... just .Lcode here and .LisVirtualKey on the next line.
Something far closer to the original would likely be best here. I'm confident that we don't even need to create an intermediary event object... and that'll let us bypass the need for the other change - the optional-based null guard.
This uses a different approach in response to code review. Fixes #10099.
2c5eb6e to
38c7839
Compare
|
When this is resolved, we'll want to 🍒 pick to stable-16.0 so keymanweb.com gets the fix. |
|
Changes in this pull request will be available for download in Keyman version 17.0.226-alpha |
Fixes #10099.
User Testing
TEST_FIXED: