-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[Feature]: Overflow should allow for configuration of gap per item #33643
Comments
Hello @mathis-m, currently there's a workaround for a gap in the Overflow component. |
Thanks, my workaround is to add padding within the item itself, depending on its index and if overflow button is shown or not. |
Personally I feel that the |
Just my two cents: Fluent Ui is so mature and uses so many great concepts in v9, I think it would be worth investing a little time into the great Overflow component(really useful), to find an algorithm that just works, without declarative padding and supports CSS Grid and Flex gaps! Eg. Find most offset item on axis and use offset and element size to calculate the overflow items. Instead of building a sum over all widths. This would be more versatile and supports gaps and probably even static positioning! |
This is essentially a duplicate of #23066 We've been aware of this issue, and haven't prioritized it yet since the main difficulty is that there is no way in the DOM API to measure margins/gaps in the bounding box model. Even if we added some kind of prop to declare regular spacing there's no guarantee it won't get out of sync with what the layouting engine actually makes those gaps. We've been recommending folks to use the padding workaround for now - it's the option that has the least amount of effort |
Going to close this and track this problem under the eixsting issue #23066 Please drop a like and a bump in that issue so we can know the interest and reprioritize |
Area
React Components (@fluentui/react-components)
Describe the feature that you would like added
Currently it is not posible to define the exact gap between items so that at any given point in time the visible items are hidden at the exact time of overflow.
We can only provide a static padding, this results for early overflow when resizing smaller. This is getting more noticable for whenn many items are used with a larger gap.
Eg. 10 items (100px width), gap 20px => padding 200px
Item 2 will be hidden at 399px container width, Even tho it would fit until 220px container width
Example dynamic padding based on visible item count: [Item 1] [Item 2] [Item 3]
General State
Item width: 100px
Gap: 10px
Initial state for Overflow
Overflow Padding: 20px
Container size: 320px
Container Resize
Container size: 319px
Overflow Manager will hide Item 3 because
3 * 100 > 319 - 20
Example is now: [Item 1] [Item 2]
Option 1: In order for the overflow to happen after resizing at 209px the padding needs to be in total 10px.
Option 2: But the padding as well needs to be 20px so that the overflow can happen after resizing to 320px. Otherwise it would already show item 3 at 310px when we would use 10px for padding.
Even if we would use 10px (Option 1, set padding to actual total padding currently in use) this would introduce a flickering as the overflow manager (instances, plural because if the options change a new instance is created) would oscillate between 3 and 2 items:
container size: 319px
padding: 20px
3 * 100 > 319 - 20
=> Item 3 hide3 * 100 < 319 - 10
=> all are shown3 * 100 < 319 - 20
=> Item 3 is hiddenRelated Code for proccesing of items:
fluentui/packages/react-components/priority-overflow/src/overflowManager.ts
Lines 141 to 176 in 5964b11
Re-instantiate of manager
fluentui/packages/react-components/react-overflow/library/src/useOverflowContainer.ts
Lines 71 to 89 in 5964b11
Add all items to visible queue after instantiate
fluentui/packages/react-components/priority-overflow/src/overflowManager.ts
Line 190 in 5964b11
Missing Option from my perspective
Provide a way to either statically define a space between items and padding per item, that is used based on items visible.
Provide a function that is called per item to let the user decide based on id and index what the total padding is.
Is there a better solution to process overflow
Probably, yes, is there any reason why we use width sum instead of reverse iterating and checking x coordinate plus width?
If coordinate would be used, all the css gap would work ootb.
Additional context
No response
Have you discussed this feature with our team
No response
Validations
Priority
Low
The text was updated successfully, but these errors were encountered: