Skip to content

Commit 396993e

Browse files
authored
fix(ui5-segmentedbutton): fix rendering in ie (#1622)
1 parent 32bd38d commit 396993e

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

packages/main/src/SegmentedButton.js

+20-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import ItemNavigation from "@ui5/webcomponents-base/dist/delegate/ItemNavigation
33
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
44
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
55
import ResizeHandler from "@ui5/webcomponents-base/dist/delegate/ResizeHandler.js";
6+
import RenderScheduler from "@ui5/webcomponents-base/dist/RenderScheduler.js";
7+
import { isIE } from "@ui5/webcomponents-base/dist/Device.js";
68
import { SEGMENTEDBUTTON_ARIA_DESCRIPTION } from "./generated/i18n/i18n-defaults.js";
79
import ToggleButton from "./ToggleButton.js";
810

@@ -125,8 +127,24 @@ class SegmentedButton extends UI5Element {
125127
}
126128

127129
async onAfterRendering() {
128-
await Promise.all(this.buttons.map(button => button._waitForDomRef));
129-
this.widths = this.buttons.map(button => button.offsetWidth);
130+
await this.measureButtonsWidth();
131+
}
132+
133+
async measureButtonsWidth() {
134+
await RenderScheduler.whenDOMUpdated();
135+
136+
this.widths = this.buttons.map(button => {
137+
// +1 is added because for width 100.44px the offsetWidth property returns 100px and not 101px
138+
let width = button.offsetWidth + 1;
139+
140+
if (isIE()) {
141+
// in IE we are adding 1 one px beacause the width of the border on a button in the middle is not calculated and if the
142+
// longest button is in the middle, it truncates
143+
width += 1;
144+
}
145+
146+
return width;
147+
});
130148
}
131149

132150
initItemNavigation() {

0 commit comments

Comments
 (0)