Skip to content

Toolbar items physical #11374

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

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open

Conversation

PetyaMarkovaBogdanova
Copy link
Contributor

@PetyaMarkovaBogdanova PetyaMarkovaBogdanova commented Apr 22, 2025

Toolbar items made physical.
Fixes: #10622

@PetyaMarkovaBogdanova PetyaMarkovaBogdanova marked this pull request as ready for review May 9, 2025 12:59
Copy link
Contributor

@dobrinyonkov dobrinyonkov left a comment

Choose a reason for hiding this comment

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

A few class members that are no longer used can be deleted:

Toolbar

  • getRegisteredToolbarItemByID
    • and itemsDOM
  • getItemByID
  • hasItemWithText
    • and ToolbarItem's containsText
  • itemsWidthMeasured

ToolbarItem

  • containsText
  • toolbarTemplate
  • toolbarPopoverTemplate

PR's title needs to include the refactor semantic tag.
Also, we can describe a short summary of the changes in the PR's body.

@@ -502,16 +500,7 @@ class Toolbar extends UI5Element {

getItemsInfo(items: Array<ToolbarItem>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can delete this method as it no longer provides any value, we can work with this.items directly.

*/

@property({ type: Boolean })
_isOverflowed: boolean = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

As this is used by the subclasses which inherit the toolbar item, this property is protected. We can also define it without the underslash.


registerToolbarItem(ToolbarButton);
get class() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's refactor the classes getter to return ClassMap:

Parent

	get classes() {
		return {
		    "ui5-tb-popover-item": this._isOverflowed,
		    "ui5-tb-item": true
		};
	}

Child

	/**
	 * @override
	 */
	get classes() {
		return {
		    ...super.classes,
		    "ui5-tb-button": true
		};
	}

width: this.width,
display: this.hidden ? "none" : "inline-block",
width: this.width || "100%",
display: this.hidden ? "none" : "block",
Copy link
Contributor

Choose a reason for hiding this comment

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

The line display: this.hidden ? "none" : "block", must no longer be needed as the hidden attribute will affect the physical item. We also have a private property hidden #10915 (comment) that can also be removed.

return this._isOverflowed ? "ui5-tb-popover-item" : "ui5-tb-item" as string;
}

getFocusDomRef(): HTMLElement | undefined {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is needed because we've added a little "hack" in the toolbar, overriding the _getRealDomRef of each items

item._getRealDomRef = () => this.getDomRef()!.querySelector(`[data-ui5-stable*=${item.stableDomRef}]`)

If you check, even the getDomRef is not working.

Removing the hack (which is no longer needed) should fix both the getDomRef and getFocusDomRef methods, without any overrides.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ui5-toolbar]:implement toolbar components as a physical one
2 participants