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

MM-42320 Remove excess keyboard listeners from post components #9708

Merged
merged 3 commits into from
Feb 1, 2022

Conversation

hmhealey
Copy link
Member

@hmhealey hmhealey commented Jan 26, 2022

Similar to #9707, each post renders a keyboard handler to detect whether or not alt is pressed because that switches the cursor to show that you can click on a post to mark it as unread. This happens once for each post on the screen which can add a bit of processing time when a user is typing a message.

By only registering those handlers when the user hovers over a post, we ensure that we only have one registered at a time at most which should hopefully speed up typing performance slightly.

Ticket Link

https://mattermost.atlassian.net/browse/MM-41320

Related Pull Requests

#9707

Screenshots

Here's a before and after with log statements added to the listeners.

Before:

before.mov

After:

after.mov

Release Note

Reduce the number of post components listening for keyboard 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

@michelengelen michelengelen left a comment

Choose a reason for hiding this comment

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

LGTM ... although I feel like all of these components do basically the same thing and we can probably extract it into one component that is being used anywhere a text input is needed.

WDYT @hmhealey @matthewbirtch ?

PS: this is definitely OOS for this PR, but we should definitely think about it!

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
Copy link
Member Author

Yeah, that's 100% something I'd like to do. The post components (and post textboxes) have so much duplicated code, but they're not something we've had a chance to get to yet. We do have a goal for the year to refactor some areas of heavy tech debt, and those are both high up for me on that list.

Alternatively, I feel like that could make a good custom hook, but we can't do that either until these components are rewritten to be functional

@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 @M-ZubairAhmed
Tested, looks good to merge.

  • Verified cursor turns to a hand pointer when holding alt and hovering over a post. Additionally, when holding alt key while the mouse cursor is not hovering over any post, the cursor is not changing to hand pointer.
  • E2E report looks 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 ad36421 into master Feb 1, 2022
@jgilliam17 jgilliam17 deleted the MM-42320_post-listeners branch February 1, 2022 02:51
@amyblais amyblais added this to the v6.5.0 milestone Feb 4, 2022
@amyblais amyblais added Changelog/Done Required changelog entry has been written Docs/Not Needed Does not require documentation labels 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#9708)

* MM-42320 Remove excess keyboard listeners from post components

* Update snapshots

Co-authored-by: Mattermod <[email protected]>
(cherry picked from commit ad36421)
@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
#9800)

* MM-42320 Remove excess keyboard listeners from post components

* Update snapshots

Co-authored-by: Mattermod <[email protected]>
(cherry picked from commit ad36421)

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
7 participants