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

Commit

Permalink
Don't close statusmenu on header click (#9363)
Browse files Browse the repository at this point in the history
Automatic Merge
  • Loading branch information
iOSGeekster authored Nov 26, 2021
1 parent c8d87cb commit fbf5f76
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ exports[`components/StatusDropdown should match snapshot in default state 1`] =
Object {
"direction": "right",
"id": "dndSubMenu-header",
"isHeader": true,
"text": "Disable notifications until:",
},
Object {
Expand Down Expand Up @@ -364,6 +365,7 @@ exports[`components/StatusDropdown should match snapshot with custom status and
Object {
"direction": "right",
"id": "dndSubMenu-header",
"isHeader": true,
"text": "Disable notifications until:",
},
Object {
Expand Down Expand Up @@ -611,6 +613,7 @@ exports[`components/StatusDropdown should match snapshot with custom status enab
Object {
"direction": "right",
"id": "dndSubMenu-header",
"isHeader": true,
"text": "Disable notifications until:",
},
Object {
Expand Down Expand Up @@ -858,6 +861,7 @@ exports[`components/StatusDropdown should match snapshot with custom status expi
Object {
"direction": "right",
"id": "dndSubMenu-header",
"isHeader": true,
"text": "Disable notifications until:",
},
Object {
Expand Down Expand Up @@ -1106,6 +1110,7 @@ exports[`components/StatusDropdown should match snapshot with custom status puls
Object {
"direction": "right",
"id": "dndSubMenu-header",
"isHeader": true,
"text": "Disable notifications until:",
},
Object {
Expand Down Expand Up @@ -1330,6 +1335,7 @@ exports[`components/StatusDropdown should match snapshot with profile picture UR
Object {
"direction": "right",
"id": "dndSubMenu-header",
"isHeader": true,
"text": "Disable notifications until:",
},
Object {
Expand Down Expand Up @@ -1550,6 +1556,7 @@ exports[`components/StatusDropdown should match snapshot with status dropdown op
Object {
"direction": "right",
"id": "dndSubMenu-header",
"isHeader": true,
"text": "Disable notifications until:",
},
Object {
Expand Down
1 change: 1 addition & 0 deletions components/status_dropdown/status_dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ export default class StatusDropdown extends React.PureComponent<Props, State> {
id: 'dndSubMenu-header',
direction: 'right',
text: localizeMessage('status_dropdown.dnd_sub_menu_header', 'Disable notifications until:'),
isHeader: true,
} as any,
].concat(
this.dndTimes.map(({id, label, labelDefault}, index) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ exports[`components/widgets/menu/menu_items/submenu_item empty subMenu should ma
<li
className="SubMenuItem MenuItem"
id="1_menuitem"
onClick={[Function]}
role="menuitem"
>
<div
Expand Down Expand Up @@ -82,6 +83,7 @@ exports[`components/widgets/menu/menu_items/submenu_item present subMenu should
<li
className="SubMenuItem MenuItem"
id="1_menuitem"
onClick={[Function]}
role="menuitem"
>
<div
Expand Down Expand Up @@ -132,6 +134,7 @@ exports[`components/widgets/menu/menu_items/submenu_item present subMenu should
<li
className="SubMenuItem MenuItem"
id="A_menuitem"
onClick={[Function]}
role="menuitem"
>
<div
Expand Down Expand Up @@ -186,6 +189,7 @@ exports[`components/widgets/menu/menu_items/submenu_item present subMenu should
<li
className="SubMenuItem MenuItem"
id="B_menuitem"
onClick={[Function]}
role="menuitem"
>
<div
Expand Down
9 changes: 8 additions & 1 deletion components/widgets/menu/menu_items/submenu_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export type Props = {
styleSelectableItem?: boolean;
extraText?: string;
rightDecorator?: React.ReactNode;
isHeader?: boolean;
}

type State = {
Expand Down Expand Up @@ -85,8 +86,12 @@ export default class SubMenuItem extends React.PureComponent<Props, State> {

private onClick = (event: React.SyntheticEvent<HTMLElement>) => {
event.preventDefault();
const {id, postId, subMenu, action, root} = this.props;
const {id, postId, subMenu, action, root, isHeader} = this.props;
const isMobile = Utils.isMobile();
if (isHeader) {
event.stopPropagation();
return;
}
if (isMobile) {
if (subMenu && subMenu.length) { // if contains a submenu, call openModal with it
if (!root) { //required to close only the original menu
Expand Down Expand Up @@ -185,6 +190,7 @@ export default class SubMenuItem extends React.PureComponent<Props, State> {
ariaLabel={ariaLabel}
root={false}
direction={s.direction}
isHeader={s.isHeader}
/>
{s.text === selectedValueText && <span className='sorting-menu-checkbox'>
<i className='icon-check'/>
Expand All @@ -202,6 +208,7 @@ export default class SubMenuItem extends React.PureComponent<Props, State> {
role='menuitem'
id={id + '_menuitem'}
ref={this.node}
onClick={this.onClick}
>
<div
className={classNames([{styleSelectableItemDiv: styleSelectableItem}])}
Expand Down
11 changes: 11 additions & 0 deletions e2e/cypress/integration/menus/status_dropdown_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// Stage: @prod
// Group: @menu @custom_status @status_menu

import * as TIMEOUTS from '../../fixtures/timeouts';
import theme from '../../fixtures/theme.json';

describe('Status dropdown menu', () => {
Expand Down Expand Up @@ -79,6 +80,16 @@ describe('Status dropdown menu', () => {
// # Open user menu to verify it still open up and visible
cy.uiOpenUserMenu();
});

it('MM-T4420 Should stay open when dnd sub-menu header is clicked', () => {
// # Open Dnd sub menu and click on header
cy.uiOpenDndStatusSubMenu().find('#dndSubMenu-header_menuitem').click().then(() => {
cy.wait(TIMEOUTS.HALF_SEC);

// * Verify that dnd submenu is still visible
cy.get('body').find('#dndSubMenu-header_menuitem').should('be.visible');
});
});
});

function stepThroughStatuses(statusTestCases = []) {
Expand Down

0 comments on commit fbf5f76

Please sign in to comment.