Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui5-shellbar): allow selection with Enter key in overflow menu #4577

Merged
merged 5 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion packages/base/hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
IF02uasMJ8CyePMyWQYW52sY6Zk=
9Cw2r3iroIa9+t3zf9W9NFHa8/I=
26 changes: 12 additions & 14 deletions packages/fiori/src/ShellBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getFeature } from "@ui5/webcomponents-base/dist/FeaturesRegistry.js";
import AnimationMode from "@ui5/webcomponents-base/dist/types/AnimationMode.js";
import { getAnimationMode } from "@ui5/webcomponents-base/dist/config/AnimationMode.js";
import { isSpace, isEnter } from "@ui5/webcomponents-base/dist/Keys.js";
import { renderFinished } from "@ui5/webcomponents-base/dist/Render.js";
import StandardListItem from "@ui5/webcomponents/dist/StandardListItem.js";
import List from "@ui5/webcomponents/dist/List.js";
import Popover from "@ui5/webcomponents/dist/Popover.js";
Expand Down Expand Up @@ -160,10 +161,6 @@ const metadata = {
type: Object,
},

_actionList: {
type: Object,
},

_header: {
type: Object,
},
Expand Down Expand Up @@ -459,16 +456,6 @@ class ShellBar extends UI5Element {
// marks if preventDefault() is called in item's press handler
this._defaultItemPressPrevented = false;

this._actionList = {
itemPress: event => {
if (!this._defaultItemPressPrevented) {
this.overflowPopover.close();
}

this._defaultItemPressPrevented = false;
},
};

this.menuItemsObserver = new MutationObserver(() => {
this._updateClonedMenuItems();
});
Expand Down Expand Up @@ -746,6 +733,17 @@ class ShellBar extends UI5Element {
}, 100);
}

async _handleActionListClick(event) {
if (!this._defaultItemPressPrevented) {
this.closeOverflow();
// wait for DOM to be updated when ui5-popover is closed, otherwise if Enter key is hold
// there will be no visual indication that this has happened
await renderFinished();
}

this._defaultItemPressPrevented = false;
}

_handleCustomActionPress(event) {
const refItemId = event.target.getAttribute("data-ui5-external-action-item-id");

Expand Down
2 changes: 1 addition & 1 deletion packages/fiori/src/ShellBarPopover.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@ui5-before-open={{_overflowPopoverBeforeOpen}}
@ui5-after-close={{_overflowPopoverAfterClose}}
>
<ui5-list separators="None" @ui5-item-click="{{_actionList.itemPress}}">
<ui5-list separators="None" @ui5-item-click="{{_handleActionListClick}}">
{{#each _hiddenIcons}}
<ui5-li
data-ui5-external-action-item-id="{{this.refItemid}}"
Expand Down