@@ -138,7 +138,7 @@ function Breadcrumbs({className, children, sx: sxProp, overflow = 'wrap', hideRo
138
138
currentMenuItems = itemsToHide
139
139
currentVisibleItems = childArray . slice ( childArray . length - 4 )
140
140
}
141
-
141
+ let eHideRoot = hideRoot
142
142
// Now check if current visible items fit in available width
143
143
if ( availableWidth > 0 ) {
144
144
let visibleItemsWidthTotal = calculateVisibleItemsWidth ( currentVisibleItems )
@@ -148,13 +148,11 @@ function Breadcrumbs({className, children, sx: sxProp, overflow = 'wrap', hideRo
148
148
visibleItemsWidthTotal += MENU_BUTTON_WIDTH
149
149
}
150
150
151
- // Progressive hiding: keep moving items to menu until they fit
152
- let effectiveHideRoot = hideRoot
153
151
while ( visibleItemsWidthTotal > availableWidth && currentVisibleItems . length > 1 ) {
154
152
// Determine which item to hide based on hideRoot setting
155
153
let itemToHide : React . ReactElement
156
154
157
- if ( effectiveHideRoot ) {
155
+ if ( eHideRoot ) {
158
156
// Hide from start when hideRoot is true
159
157
itemToHide = currentVisibleItems [ 0 ]
160
158
currentVisibleItems = currentVisibleItems . slice ( 1 )
@@ -166,7 +164,6 @@ function Breadcrumbs({className, children, sx: sxProp, overflow = 'wrap', hideRo
166
164
167
165
currentMenuItems = [ itemToHide , ...currentMenuItems ]
168
166
169
- // Recalculate width
170
167
visibleItemsWidthTotal = calculateVisibleItemsWidth ( currentVisibleItems )
171
168
172
169
// Add menu button width
@@ -178,17 +175,15 @@ function Breadcrumbs({className, children, sx: sxProp, overflow = 'wrap', hideRo
178
175
// fallback to hideRoot=true behavior (menu + leaf only)
179
176
if (
180
177
! hideRoot &&
181
- ! effectiveHideRoot &&
178
+ ! eHideRoot &&
182
179
currentVisibleItems . length === 2 &&
183
180
visibleItemsWidthTotal > availableWidth
184
181
) {
185
- effectiveHideRoot = true
186
- // Move the root item to menu as well
182
+ eHideRoot = true
187
183
const rootItem = currentVisibleItems [ 0 ]
188
184
currentVisibleItems = currentVisibleItems . slice ( 1 )
189
185
currentMenuItems = [ rootItem , ...currentMenuItems ]
190
186
191
- // Recalculate width one more time
192
187
visibleItemsWidthTotal = calculateVisibleItemsWidth ( currentVisibleItems )
193
188
194
189
if ( currentMenuItems . length > 0 ) {
@@ -197,21 +192,19 @@ function Breadcrumbs({className, children, sx: sxProp, overflow = 'wrap', hideRo
197
192
}
198
193
}
199
194
}
200
-
201
195
return {
202
196
visibleItems : currentVisibleItems ,
203
197
menuItems : currentMenuItems ,
204
- effectiveHideRoot,
198
+ effectiveHideRoot : eHideRoot ,
205
199
}
206
200
}
207
201
208
- // Apply the overflow calculation
209
202
const result = calculateOverflow ( containerWidth )
210
203
setVisibleItems ( result . visibleItems )
211
204
setMenuItems ( result . menuItems )
212
205
setEffectiveHideRoot ( result . effectiveHideRoot )
213
206
}
214
- } , [ childArray , overflow , containerWidth , hideRoot , itemWidths , effectiveHideRoot ] )
207
+ } , [ childArray , overflow , containerWidth , hideRoot , itemWidths ] )
215
208
216
209
// Determine final children to render
217
210
const finalChildren = React . useMemo ( ( ) => {
0 commit comments