-
Notifications
You must be signed in to change notification settings - Fork 275
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
base: main
Are you sure you want to change the base?
Toolbar items physical #11374
Conversation
This reverts commit 79216a5.
…ents into toolbar-items-physical
There was a problem hiding this 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
- and
getItemByID
hasItemWithText
- and ToolbarItem's
containsText
- and ToolbarItem's
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>) { |
There was a problem hiding this comment.
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.
packages/main/src/ToolbarItem.ts
Outdated
*/ | ||
|
||
@property({ type: Boolean }) | ||
_isOverflowed: boolean = false; |
There was a problem hiding this comment.
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.
packages/main/src/ToolbarButton.ts
Outdated
|
||
registerToolbarItem(ToolbarButton); | ||
get class() { |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
Toolbar items made physical.
Fixes: #10622