Skip to content

Commit

Permalink
fix(editor): Arrow control on firefox
Browse files Browse the repository at this point in the history
I forgor to check which key was pressed.
Due to an edge case, in which Firefox required 2 key presses to move from math to text, pressing left twice causes the editor to think you want to go left.
However, this only affected Firefox users, so we'll just fix this quietly :)
  • Loading branch information
Esinko authored Sep 8, 2023
1 parent d58d33c commit 3d0ecbf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/math-editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,15 @@ class Editor {
if ( // At start (from right)
documentSelection.anchorNode.nodeName.toLowerCase() === "#text" &&
elementList[selectionIndex - 1]?.nodeName === "MATH" &&
documentSelection.anchorOffset === 0
documentSelection.anchorOffset === 0 &&
event.code === "ArrowLeft"
) {
focus(elementList[selectionIndex - 1])
} else if ( // At end (from left)
documentSelection.anchorNode.nodeName.toLowerCase() === "#text" &&
elementList[selectionIndex + 1]?.nodeName === "MATH" &&
documentSelection.anchorOffset === documentSelection.anchorNode.textContent.length
documentSelection.anchorOffset === documentSelection.anchorNode.textContent.length &&
event.code === "ArrowRight"
) {
focus(elementList[selectionIndex + 1])
}
Expand Down

0 comments on commit 3d0ecbf

Please sign in to comment.