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

Don't close statusmenu on header click #9363

Merged
merged 4 commits into from
Nov 26, 2021

Conversation

iOSGeekster
Copy link
Contributor

Summary

Fixes that the status dropdown closes, when clicking the "header"

I havn't added test as of yet, because I think it would be good to get some feedback on the potential fix first.

I'm not sure it's the optimal approach... Thing is that the click event bubbles all the way up to the menu, which then closes the dropdown. So I tried the make the same approach as we do in menu_group, where we disabled click for the dividers.

Ticket Link

Fixes https://mattermost.atlassian.net/browse/MM-39742

NONE

@mattermod
Copy link
Contributor

Hello @iOSGeekster,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

@mattermod mattermod requested review from a team and devinbinnie and removed request for a team November 12, 2021 08:08
@mattermod mattermod added 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester Contributor labels Nov 12, 2021
Copy link
Member

@devinbinnie devinbinnie left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @iOSGeekster!

@iOSGeekster
Copy link
Contributor Author

Would it make a sense to add a E2E test that verifies this? As I see it, it can't be tested isolated in submenu_item.test.tsx, but I could be mistaken. So maybe it would make sense to create a integration test with cypress, but if that is the case, it should probably be connected to at test case or something like that?

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

@michelengelen
Copy link
Contributor

@iOSGeekster adding E2E for this might make sense.

Although I just had an idea that would make the implementation and testing via Jest a bit easier.

Why not remove the event.stopPropagation if-block from the onClick handler and instead add a ternary to the onClick property like this?

return (
    <li
        className={classNames(['SubMenuItem MenuItem', {styleSelectableItem}])}
        role='menuitem'
        id={id + '_menuitem'}
        ref={this.node}
        onClick={this.props.isHeader ? this.onClick : null}
    >
        // ...
    </li>
);

That way you could test for the function to being called in the unit test instead of writing a cypress test for that.

WDYT?

cc/ @devinbinnie

@iOSGeekster
Copy link
Contributor Author

@iOSGeekster adding E2E for this might make sense.

Although I just had an idea that would make the implementation and testing via Jest a bit easier.

Why not remove the event.stopPropagation if-block from the onClick handler and instead add a ternary to the onClick property like this?

return (
    <li
        className={classNames(['SubMenuItem MenuItem', {styleSelectableItem}])}
        role='menuitem'
        id={id + '_menuitem'}
        ref={this.node}
        onClick={this.props.isHeader ? this.onClick : null}
    >
        // ...
    </li>
);

That way you could test for the function to being called in the unit test instead of writing a cypress test for that.

WDYT?

cc/ @devinbinnie

I think that's a good idea. I'll go ahead and make those modifications.

@iOSGeekster
Copy link
Contributor Author

Hmm... just off the bat, it seems like the stopPropagation() is needed. Or else the click event will bubble up to the status menu itself, (and not just the submenu) and toggle the menu, making it disappear.

@michelengelen
Copy link
Contributor

michelengelen commented Nov 17, 2021

@iOSGeekster in that case we could setup a new helper function that prevents that from happening and pass it instead of null in the condition. But that is something the webapp team needs to decide since this would mean to create a new pattern that is not being used as of now.

EDIT: Thinking of it now I think it might be a little overkill to add that only to get testing a bit more convenient.

Thoughts @hmhealey ?

@hmhealey
Copy link
Member

If we're adding a test for this, I think I'd prefer an E2E test anyway since we'll know 100% that this does what we want (ie not closing the menu). If we're changing the code in that way, I feel like we're testing that the code does what it says, not that the code does what we actually want to.

We could still change how the code works though. I'm 0/5 on that.

@michelengelen
Copy link
Contributor

yep ... agreed! After sleeping over it it does feel like we are adding something out of convenience. So E2E might be best here as @hmhealey says.

@iOSGeekster
Copy link
Contributor Author

That sounds like a good idea. Does it need at test-case to be created? Most of the E2E test are tied up to at test-case number, ie. MM-XXXX

@michelengelen
Copy link
Contributor

@iOSGeekster that sounds like a question for @jgilliam17 or @saturninoabril ... Could one of you help out here please? 🙇🏼‍♂️

@saturninoabril
Copy link
Member

@iOSGeekster Please go ahead and write E2E with the test scenario you have in mind then we'll validate and generate the corresponding test case ID.

@saturninoabril saturninoabril self-requested a review November 24, 2021 10:57
@iOSGeekster
Copy link
Contributor Author

@iOSGeekster Please go ahead and write E2E with the test scenario you have in mind then we'll validate and generate the corresponding test case ID.

Cool! Will do, and ping you once it's ready. Thanks guys 🙌

@iOSGeekster
Copy link
Contributor Author

@saturninoabril I've added a simple e2e test, that validates it.

@iOSGeekster
Copy link
Contributor Author

/update-branch

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

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 @iOSGeekster
I added the test case reference number
@saturninoabril I ran the E2Es, but not able to find this test. I can re-run after the reference number is updated. Any suggestions? Disregard, I opened the wrong report. This run is still pending

@jgilliam17 jgilliam17 added the Setup Cloud Test Server Setup a test server using Mattermost Cloud label Nov 26, 2021
@jgilliam17
Copy link
Contributor

jgilliam17 commented Nov 26, 2021

E2E report https://mattermost-cypress-report.s3.amazonaws.com/90559-311aedb-ee-ent-webapp-pr-9363-mm-ee-test:311aedb/mochawesome.html
Screen Shot 2021-11-26 at 1 05 03 PM

Thanks @iOSGeekster
Tested, looks good to merge.

  • Verified DND time options header no longer closes on click. Test created in Zephyr and reference number suggested.

Co-authored-by: Jelena Gilliam <52937121+jgilliam17@users.noreply.github.com>
Copy link
Member

@saturninoabril saturninoabril left a comment

Choose a reason for hiding this comment

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

Thanks @iOSGeekster, LGTM! And thanks @jgilliam17 for adding the test case!

@saturninoabril saturninoabril added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester Setup Cloud Test Server Setup a test server using Mattermost Cloud labels Nov 26, 2021
@mm-cloud-bot
Copy link

Test server destroyed

@saturninoabril saturninoabril added the AutoMerge used by Mattermod to merge PR automatically label Nov 26, 2021
@mattermod
Copy link
Contributor

Will try to auto merge this PR once all tests and checks are passing. This might take up to an hour.

@mm-cloud-bot
Copy link

Test server creation failed. See the logs for more information.

@mattermod
Copy link
Contributor

Trying to auto merge this PR.

@mattermod mattermod merged commit fbf5f76 into mattermost:master Nov 26, 2021
@mattermod
Copy link
Contributor

Pull Request successfully merged
SHA: fbf5f76

@mattermod mattermod removed the AutoMerge used by Mattermod to merge PR automatically label Nov 26, 2021
@amyblais amyblais added Changelog/Done Required changelog entry has been written Docs/Not Needed Does not require documentation labels Dec 1, 2021
@amyblais amyblais added this to the v6.3.0 milestone Dec 1, 2021
cleferman pushed a commit to cleferman/mattermost-webapp that referenced this pull request Dec 21, 2021
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 Contributor Docs/Not Needed Does not require documentation release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants