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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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