File tree 1 file changed +20
-2
lines changed
1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import ItemNavigation from "@ui5/webcomponents-base/dist/delegate/ItemNavigation
3
3
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js" ;
4
4
import { fetchI18nBundle , getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js" ;
5
5
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" ;
6
8
import { SEGMENTEDBUTTON_ARIA_DESCRIPTION } from "./generated/i18n/i18n-defaults.js" ;
7
9
import ToggleButton from "./ToggleButton.js" ;
8
10
@@ -125,8 +127,24 @@ class SegmentedButton extends UI5Element {
125
127
}
126
128
127
129
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
+ } ) ;
130
148
}
131
149
132
150
initItemNavigation ( ) {
You can’t perform that action at this time.
0 commit comments