Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

MM-41319 Reduced number of listeners registered by MenuWrapper #9707

Merged
merged 3 commits into from
Feb 1, 2022

Conversation

hmhealey
Copy link
Member

@hmhealey hmhealey commented Jan 26, 2022

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

Reduce the number of menu components listening for keyboard and mouse events

@hmhealey hmhealey added 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester labels Jan 26, 2022
Copy link
Contributor

@larkox larkox left a 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);
Copy link
Contributor

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)

Copy link
Member Author

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 😛

Copy link
Member

@M-ZubairAhmed M-ZubairAhmed left a 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

@M-ZubairAhmed M-ZubairAhmed removed the 2: Dev Review Requires review by a core commiter label Jan 27, 2022
@hmhealey hmhealey added the Setup Cloud Test Server Setup a test server using Mattermost Cloud label Jan 27, 2022
@jgilliam17
Copy link
Contributor

/update-branch

@jgilliam17
Copy link
Contributor

/e2e-test

@mattermod
Copy link
Contributor

Triggering e2e testing with options:
<nil>

@mattermod
Copy link
Contributor

Copy link
Contributor

@jgilliam17 jgilliam17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hmhealey
Tested, looks good to merge.

  • Verified channel and category menus in the LHS are working as expected.
  • E2Es look good, no PR related failures.

@jgilliam17 jgilliam17 added 4: Reviews Complete All reviewers have approved the pull request and removed 3: QA Review Requires review by a QA tester Setup Cloud Test Server Setup a test server using Mattermost Cloud labels Feb 1, 2022
@mm-cloud-bot
Copy link

Test server destroyed

@jgilliam17 jgilliam17 merged commit d500ab7 into master Feb 1, 2022
@jgilliam17 jgilliam17 deleted the MM-41319_menu-wrapper-listeners branch February 1, 2022 03:21
@amyblais amyblais added Changelog/Done Required changelog entry has been written Docs/Not Needed Does not require documentation labels Feb 4, 2022
@amyblais amyblais added this to the v6.5.0 milestone Feb 4, 2022
@amyblais
Copy link
Member

/cherry-pick release-6.3

@mattermod
Copy link
Contributor

Cherry pick is scheduled.

mattermost-build pushed a commit to mattermost-build/mattermost-webapp that referenced this pull request Feb 11, 2022
…rmost#9707)

* MM-41319 Reduced number of listeners registered by MenuWrapper

* Fix linting

Co-authored-by: Mattermod <[email protected]>
(cherry picked from commit d500ab7)
@mattermod mattermod added the CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone label Feb 11, 2022
hmhealey added a commit that referenced this pull request Feb 11, 2022
#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]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Done Required changelog entry has been written CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone Docs/Not Needed Does not require documentation release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants