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

feat(ui5-menu): refactor menu items display #8259

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e998cc1
feat(ui5-menu): use custom list items as base for menu items
unazko Feb 7, 2024
e0d0b99
feat(ui5-menu): use custom list items as base of the menu items
unazko Feb 7, 2024
b4bc6e5
feat(ui5-menu): refactor menu items display
unazko Feb 8, 2024
90eff73
feat(ui5-menu): refactor menu items display
unazko Feb 8, 2024
c14bcac
feat(ui5-menu): refactor menu items display
unazko Feb 8, 2024
47cabb2
feat(ui5-menu): refactor menu items display
unazko Feb 8, 2024
df44060
feat(ui5-menu): refactor menu items display
unazko Feb 8, 2024
9b3435b
feat(ui5-menu): refactor menu items display
unazko Feb 8, 2024
494076e
feat(ui5-menu): refactor menu items display
unazko Feb 8, 2024
58c4976
feat(ui5-menu): refactor menu items display
unazko Feb 8, 2024
b2e74da
feat(ui5-menu): refactor menu items display
unazko Feb 8, 2024
6dbdb43
feat(ui5-menu): refactor menu items display
unazko Feb 9, 2024
e23deb9
feat(ui5-menu): refactor menu items display
unazko Feb 9, 2024
46b8f8f
feat(ui5-menu): refactor menu items display
unazko Feb 9, 2024
0c282f6
feat(ui5-menu): refactor menu items display
unazko Feb 10, 2024
c623729
feat(ui5-menu): refactor menu items display
unazko Feb 10, 2024
c77f865
feat(ui5-menu): refactor menu items display
unazko Feb 12, 2024
b218ffb
feat(ui5-menu): refactor menu items display
unazko Feb 12, 2024
2ad0e5b
feat(ui5-menu): refactor menu items display
unazko Feb 12, 2024
feff9c5
feat(ui5-menu): refactor menu items display
unazko Feb 12, 2024
7f4a930
feat(ui5-menu): refactor menu items display
unazko Feb 12, 2024
475e0ef
feat(ui5-menu): refactor menu items display
unazko Feb 12, 2024
822f163
feat(ui5-menu): refactor menu items display
unazko Feb 12, 2024
90105b1
feat(ui5-menu): refactor menu items display
unazko Feb 12, 2024
898150b
feat(ui5-menu): refactor menu items display
unazko Feb 12, 2024
4941aa4
feat(ui5-menu): refactor menu items display
unazko Feb 12, 2024
493367b
feat(ui5-menu): refactor menu items display
unazko Feb 13, 2024
8001cbd
feat(ui5-menu): refactor menu items display
unazko Feb 14, 2024
f2617d4
feat(ui5-menu): refactor menu items display
unazko Feb 14, 2024
d638c11
feat(ui5-menu): refactor menu items display
unazko Feb 14, 2024
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
8 changes: 4 additions & 4 deletions packages/main/src/List.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ class List extends UI5Element {
}

getEnabledItems(): Array<ListItemBase> {
return this.getItems().filter(item => !item.disabled);
return this.getItems().filter(item => item._focusable);
}

getItems(): Array<ListItemBase> {
Expand Down Expand Up @@ -848,7 +848,7 @@ class List extends UI5Element {
}

if (lastTabbableEl === target) {
if (this.getFirstItem(x => x.selected && !x.disabled)) {
if (this.getFirstItem(x => x.selected && x._focusable)) {
this.focusFirstSelectedItem();
} else if (this.getPreviouslyFocusedItem()) {
this.focusPreviouslyFocusedItem();
Expand Down Expand Up @@ -1023,7 +1023,7 @@ class List extends UI5Element {
*/
focusFirstItem() {
// only enabled items are focusable
const firstItem = this.getFirstItem(x => !x.disabled);
const firstItem = this.getFirstItem(x => x._focusable);

if (firstItem) {
firstItem.focus();
Expand All @@ -1040,7 +1040,7 @@ class List extends UI5Element {

focusFirstSelectedItem() {
// only enabled items are focusable
const firstSelectedItem = this.getFirstItem(x => x.selected && !x.disabled);
const firstSelectedItem = this.getFirstItem(x => x.selected && x._focusable);

if (firstSelectedItem) {
firstSelectedItem.focus();
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/ListItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ abstract class ListItem extends ListItemBase {
}

fireItemPress(e: Event) {
if (this.isInactive) {
if (this.isInactive || this.disabled) {
return;
}
if (isEnter(e as KeyboardEvent)) {
Expand Down
8 changes: 6 additions & 2 deletions packages/main/src/ListItemBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class ListItemBase extends UI5Element implements ITabbable {
return {
main: {
"ui5-li-root": true,
"ui5-li--focusable": !this.disabled,
"ui5-li--focusable": this._focusable,
},
};
}
Expand All @@ -139,12 +139,16 @@ class ListItemBase extends UI5Element implements ITabbable {
return this.disabled ? true : undefined;
}

get _focusable() {
return !this.disabled;
}

get hasConfigurableMode() {
return false;
}

get _effectiveTabIndex() {
if (this.disabled) {
if (!this._focusable) {
return -1;
}
if (this.selected) {
Expand Down
58 changes: 7 additions & 51 deletions packages/main/src/Menu.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<ui5-responsive-popover
id="{{_id}}-menu-rp"
class="ui5-menu-rp"
horizontal-align="Left"
placement-type={{placementType}}
Expand All @@ -17,7 +16,7 @@
slot="header"
class="ui5-menu-dialog-header"
>
{{#if isSubMenuOpened}}
{{#if isSubMenuOpen}}
<ui5-button
icon="nav-back"
class="ui5-menu-back-button"
Expand All @@ -38,15 +37,15 @@
icon="decline"
design="Transparent"
aria-label="{{labelClose}}"
@click={{close}}
@click={{_closeAll}}
>
</ui5-button>
</div>
{{/if}}
<div
id="{{_id}}-menu-main"
>
{{#if _currentItems.length}}
{{#if items.length}}
<ui5-list
id="{{_id}}-menu-list"
mode="None"
Expand All @@ -55,54 +54,11 @@
separators="None"
accessible-role="menu"
@ui5-item-click={{_itemClick}}
@mouseover="{{_busyMouseOver}}"
@mouseover={{_itemMouseOver}}
@mouseout={{_itemMouseOut}}
@keydown={{_itemKeyDown}}
>
{{#each _currentItems}}
<ui5-li
.associatedItem="{{this.item}}"
class="ui5-menu-item"
id="{{../_id}}-menu-item-{{@index}}"
.icon="{{this.item.icon}}"
accessible-name={{this.item.ariaLabelledByText}}
accessible-role="menuitem"
.additionalText="{{this.item._additionalText}}"
._ariaHasPopup={{this.ariaHasPopup}}
?disabled={{this.item.disabled}}
?starts-section={{this.item.startsSection}}
?selected={{this.item.subMenuOpened}}
?is-phone={{../isPhone}}
@mouseover={{../_itemMouseOver}}
@mouseout={{../_itemMouseOut}}
@keydown={{../_itemKeyDown}}
>
<div class="ui5-menu-item-text">
{{#if this.item.hasDummyIcon}}
<div
class="ui5-menu-item-dummy-icon"
>
</div>
{{/if}}
{{this.item.text}}
{{#if this.item.hasSubmenu}}
<div
class="ui5-menu-item-submenu-icon"
>
<ui5-icon
part="subicon"
name="slim-arrow-right"
class="ui5-menu-item-icon-end"
>
</ui5-icon>
</div>
{{else if this.item._siblingsWithChildren}}
<div
class="ui5-menu-item-no-icon-end"
>
</div>
{{/if}}
</div>
</ui5-li>
{{/each}}
<slot></slot>
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need them as a slot or we need them as individual ones?

Copy link
Contributor Author

@unazko unazko Feb 14, 2024

Choose a reason for hiding this comment

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

Actually it seems to me now that I've read the documentation that the individual slot scheme would be more suitable for the ui5-navigation-menu template as there is an anchor tag wrapper around most of the ui5-navigation-menu-item's:

Sometimes, however, each child must be placed separately in the shadow root, potentially wrapped in other HTML elements, to satisfy the UX design of the component.

The currently implemented slot scheme in the ui5-menu looks clean. Not sure yet if we could use the general slot approach in the ui5-menu and at the same time individual slot approach for the ui5-navigation-menu derived component.

Additional feedback would be greatly appreciated.

</ui5-list>
{{else if busy}}
<ui5-busy-indicator
Expand Down
Loading