Repository navigation
⇧ perf: Listen for Shift in the Open Conversation's Sidebar Row Only - #18718
Draft
danny-avila wants to merge 1 commit into
Draft
danny-avila wants to merge 1 commit into
danny-avila wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Every conversation listed in the sidebar registers three listeners on the window (
keydown,keyup,blur) to know whether shift is held, and every one of them holds that as state. Each key press anywhere in the app, typing in the composer included, runs one handler per listed conversation, and pressing shift re-renders the whole list. Only one row uses the answer: holding shift swaps the open conversation's menu for archive and delete.Now only the open conversation's row listens. With 12 conversations listed the window carries one
keyuplistener where it carried 12; the count no longer grows with the list. It showed up in the first CI run of #18712, where a sidebar holding 24 conversations left by earlier specs added 72 window listeners to a count of the thread.How it works
ConvopassesisActiveConvo, which it already computed and already required before acting on the key. A row that stops being the open one forgets the key, since it may be released while nothing listens.Type of change
Testing
Tested environments/configuration:
Automated tests:
useShiftKey.spec.tsx: follows the key, leaves shift with alt alone, resets on blur, registers nothing while not enabled, and starts, stops and forgets asenabledchanges. The last two fail against the previous hook.sidebar-shift-actions.spec.ts, three scenarios: holding shift offers archive and delete on the open conversation's row alone and letting go removes them; opening another conversation moves them to its row; the window carries onekeyuplistener with 12 conversations listed. Against the build without the change the first two pass and the third reads 12.client: theConversationssuites (17 suites, 226 tests with the new hook spec).Screenshots / recordings
No user-facing change.
Risk / compatibility
A row that becomes the open one while shift is already held learns of it at the key's next repeat rather than at once. Before, every row tracked the key all the time.
Checklist