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
fix ButtonGroup overflowButton logic #1278
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you write which v3 task you were working on when noticed this issue?
Also, could you mention related v3 task in all your PRs. It's hard to guess which PR goes with which task.
@gretanausedaite Did you see the linked issue? I was working on this PR for v2 but it would have been a breaking change so moved to major release. |
Linked issue was missing v3 milestone so it wasn't in our v3 backlog. Sorry about that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw the original issue and tested this change, it is working as expected and should address the linked issue.
I'll work on adding unit tests. I was looking for feedback on the calculations. Do they make sense? I was a bit unsure about the values in overflowPlacement=start case. |
Yea I think it makes sense that when overflowPlacement=start, overflowButton will contain all the items that are not visible and show the rest (I'm going off the logic on line 115 and 125). Unit test would be great to sanity check the logic too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works perfectly! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe unit tests are still pending.
Updated unit tests and story. |
Changes
Our current ButtonGroup overflow logic looks a bit flawed because it doesn't fully take into account the overflowButton itself. So I've adjusted the calculations to assume that overflowButton is one of the visible items.
Additionally, I've adjusted the values so that overflowPlacement=start will remove items from the beginning.
Expected values when overflowPlacement=start:
Expected values when overflowPlacement=end:
Testing
Unit tests pending.
Tested in playground using this code:
App.tsx
Screen.Recording.2023-05-12.at.2.46.17.PM.mov
Docs
Briefly mentioned in migration guide: https://github.com/iTwin/iTwinUI/wiki/iTwinUI-react-v3-migration-guide#buttongroup