Skip to content

Commit 9454ab7

Browse files
authored
fix(components): fix setting contentDensity styles (#2094)
Fixes TimePicker was never considering contentDensity and did not update the styles of its popover so far. DatePicker and DateTimePicker used to call updateStaticAreaItemContentDensity before the staticAreaItem DOM is available. Solution: Handle setting the contentDensity on framework level when possible and remove updateStaticAreaItemContentDensity calls from ShellBar, ComboBox, Select, Input, MultiCombobox. The updateStaticAreaItemContentDensity method exists and used in the TabContainer only, because the component does not invalidate on overflow popover open/close and needs to force the contentDensity update. FIXES #2093
1 parent 5d7e7df commit 9454ab7

File tree

8 files changed

+9
-11
lines changed

8 files changed

+9
-11
lines changed

packages/base/src/StaticAreaItem.js

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class StaticAreaItem {
3636
this._rendered = true;
3737
}
3838

39+
this._updateContentDensity(this.ui5ElementContext.isCompact);
3940
this.ui5ElementContext.constructor.render(renderResult, this.staticAreaItemDomRef.shadowRoot, stylesToAdd, { eventContext: this.ui5ElementContext });
4041
}
4142

packages/fiori/src/ShellBar.js

-2
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ class ShellBar extends UI5Element {
423423
this._updateClonedMenuItems();
424424

425425
if (this.hasMenuItems) {
426-
this.updateStaticAreaItemContentDensity();
427426
const menuPopover = await this._getMenuPopover();
428427
menuPopover.openBy(this.shadowRoot.querySelector(".ui5-shellbar-menu-button"));
429428
}
@@ -635,7 +634,6 @@ class ShellBar extends UI5Element {
635634

636635
_toggleActionPopover() {
637636
const overflowButton = this.shadowRoot.querySelector(".ui5-shellbar-overflow-button");
638-
this.updateStaticAreaItemContentDensity();
639637
this.overflowPopover.openBy(overflowButton);
640638
}
641639

packages/main/src/ComboBox.js

-1
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,6 @@ class ComboBox extends UI5Element {
531531
}
532532

533533
_openRespPopover() {
534-
this.updateStaticAreaItemContentDensity();
535534
this.responsivePopover.open(this);
536535
}
537536

packages/main/src/DatePicker.js

-1
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,6 @@ class DatePicker extends UI5Element {
778778
if (this.isOpen()) {
779779
this.closePicker();
780780
} else if (this._canOpenPicker()) {
781-
this.updateStaticAreaItemContentDensity();
782781
this.openPicker();
783782
}
784783
}

packages/main/src/Input.js

-2
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,6 @@ class Input extends UI5Element {
551551
if (!this.firstRendering && !isPhone() && this.Suggestions) {
552552
const shouldOpenSuggestions = this.shouldOpenSuggestions();
553553

554-
this.updateStaticAreaItemContentDensity();
555554
this.Suggestions.toggle(shouldOpenSuggestions, {
556555
preventFocusRestore: !this.hasSuggestionItemSelected,
557556
});
@@ -657,7 +656,6 @@ class Input extends UI5Element {
657656

658657
_click(event) {
659658
if (isPhone() && !this.readonly && this.Suggestions) {
660-
this.updateStaticAreaItemContentDensity();
661659
this.Suggestions.open(this);
662660
this.isRespPopoverOpen = true;
663661
}

packages/main/src/MultiComboBox.js

-3
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ class MultiComboBox extends UI5Element {
386386
if (filteredItems.length === 0) {
387387
this.allItemsPopover.close();
388388
} else {
389-
this.updateStaticAreaItemContentDensity();
390389
this.allItemsPopover.open(this);
391390
}
392391
}
@@ -514,13 +513,11 @@ class MultiComboBox extends UI5Element {
514513
}
515514

516515
_toggleRespPopover() {
517-
this.updateStaticAreaItemContentDensity();
518516
this.allItemsPopover.toggle(this);
519517
}
520518

521519
_click(event) {
522520
if (isPhone() && !this.readonly && !this._showMorePressed) {
523-
this.updateStaticAreaItemContentDensity();
524521
this.allItemsPopover.open(this);
525522
}
526523

packages/main/src/Select.js

-2
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,6 @@ class Select extends UI5Element {
300300
return;
301301
}
302302

303-
this.updateStaticAreaItemContentDensity();
304-
305303
if (this._isPickerOpen) {
306304
this.responsivePopover.close();
307305
} else {

packages/main/test/pages/TimePicker.html

+8
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@
5555
</ui5-time-picker>
5656
<ui5-button id="testBtn">btn for testing</ui5-button>
5757

58+
59+
<section class="ui5-content-density-compact">
60+
<h3>TimePicker in Compact</h3>
61+
<div>
62+
<ui5-time-picker></ui5-time-picker>
63+
</div>
64+
</section>
65+
5866
<script>
5967
var counter = 0;
6068
timepickerChange.addEventListener("ui5-change", function() {

0 commit comments

Comments
 (0)