-
Notifications
You must be signed in to change notification settings - Fork 2.7k
MM-41319 Reduced number of listeners registered by MenuWrapper #9707
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
} | ||
|
||
private addEventListeners() { | ||
document.addEventListener('click', this.closeOnBlur, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: out of the scope of the pr, but what about moving the click
and keyup
events names to a constant? (May be in this file)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we could consider that. I don't personally think it's that helpful though since they're standard values that come from the browser. I'm not opposed to doing that, but I'm too lazy to go back and do it here 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🆗 It looks good to me. Thank you
/update-branch |
/e2e-test |
Triggering e2e testing with options: |
Successfully triggered e2e testing! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test server destroyed |
/cherry-pick release-6.3 |
Cherry pick is scheduled. |
…rmost#9707) * MM-41319 Reduced number of listeners registered by MenuWrapper * Fix linting Co-authored-by: Mattermod <[email protected]> (cherry picked from commit d500ab7)
#9801) * MM-41319 Reduced number of listeners registered by MenuWrapper * Fix linting Co-authored-by: Mattermod <[email protected]> (cherry picked from commit d500ab7) Co-authored-by: Harrison Healey <[email protected]>
Currently, every instance of MenuWrapper registers two listeners on the document that respond to every keyup and click event made in the app. With only a couple channels, this is already 12 listeners running on each key press or click, but when you have more MenuWrappers mounted (notably each sidebar channel and category uses one even if they're not visible), that starts to add up the amount of time taken to process those events.
Since both of those listeners are used to close the menu when it's open, I've changed those to only be registered once the menu gets opened and then removed when it's closed.
Ticket Link
https://mattermost.atlassian.net/browse/MM-41319
Related Pull Requests
TBD
Screenshots
I added log statements to the listeners to show when they trigger. Here's a before and after with a brand new account
Before:
before.mov
After:
after.mov
Release Note