Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Writing Flow: Avoid using state for tracking arrow key navigation #2894
This pull request seeks to refactor the WritingFlow component to eliminate state which could be set on arrow keypresses. Assigning state will incur a rerender, and for the intended usage, we do not need state to be reflected in the render result. Instead, for tracking the "should move" behavior, an instance property is sufficient and avoids any render.
I will need to look back through the old pull request, but at a glance I'm struggling to understand why we need to bind to both key down and key up, particularly because binding to key up causes a laggy feeling to the arrow movement.
Verify that there are no regressions in using arrow keys (left, right, up, down) to navigate from one input to the next / previous, e.g. between two paragraph blocks.
@@ Coverage Diff @@ ## master #2894 +/- ## ========================================== + Coverage 33.92% 33.93% +0.01% ========================================== Files 190 190 Lines 5695 5693 -2 Branches 999 999 ========================================== Hits 1932 1932 + Misses 3183 3181 -2 Partials 580 580
some context here #2424 (comment)
Basically, I first tried to only use
So I decided to use