-
Notifications
You must be signed in to change notification settings - Fork 352
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
feat(Toolbar): allow multiple toggle groups #9329
Conversation
Preview: https://patternfly-react-pr-9329.surge.sh A11y report: https://patternfly-react-pr-9329-a11y.surge.sh |
When I had been experimenting with this once upon a time, I tried doing it with separate portals. I think it's generally promising, even though it does require manipulation of more pieces. When playing with your test example, I do notice that when I expand the filter group at a small screen width, then begin resizing the window to make it wide, the styles are not adjusting like I expect them to. I'm not sure if thats a side effect of the approach. |
This second pass exposes In summary, you need:
Exposing The other slight issue is there is a grey area between ~1000px and ~1200px where a toggle group does not expand as a popup menu but instead inline, but I think that's unrelated to the changes here. @mattnolting |
@nicolethoen How does this look for a solution with the new changes? If the approach looks good lmk and I'll take it out of draft. My other open question for all is whether we want to include the example I've created in the Toolbar docs. |
I wonder if instead of asking the consumer to define their own expandable content, if we can simply create it when they need it rather than having one preexisting whose ref we pass around for using in createPortals. In that case we could take the children passed to the ToolbarToggleGroup and put them in an ExpandableContent component and place that ExpandableContent in a Popper? WDYT? |
I had experimented with putting the A user would still need to pass the chip refs around even with an internal popper, because chips are controlled in the |
idk if it helps - i have a SUPER old branch where I tinkered with this during a break away sprint. I think I removed the need for create portal. I just made a draft PR so you can easily see the diff: #9349 |
Take 3 with poppers. The caveat is that the spacing is now different, because there is no top padding on the expandable content, and popper is appending directly after the toolbar (while the createPortal method looked like it was in line with a grid gap? Shown in all toggle examples but most noticeable in the stacked example as the divider line is being lost now). The weird zone between 1000-1200px also looks more squished as the pop up is losing padding. The user doesn't have to manually create the ToolbarExpandableContent component with this setup, though they would still have to pipe a lot of those props through ToolbarToggleGroup. |
LMK what you think between the popper approach and the previous manual expandable content one. The manual expandable contents may require a bit more user definition, but the current structure of the toolbar is better preserved than when using popper. |
I like it better with less that the consumer has to wire up. |
The entire expandableContent is already given to Popper, or do you mean a different div? If you mean the div where the popper is appending to, that is how the toggle group is appearing below the toolbar line (otherwise the expandable content would be inline with the trigger filter icon). |
I played with it a bit and was trying to figure out why the padding in the expandable content was being removd/overwritten.
rather than
|
@nicolethoen I tested wrapping the expandableContent in an additional div to separate out the styling from popper, but it appears something in the two sets of styles is still in conflict. The positioning of the popper also becomes inconsistent (sometimes it will attach to the top of the page instead and only a reload reverts that position). Screen.Recording.2023-08-07.at.11.13.49.AM.mov |
@kmcfaul This is looking great! Looks like we need to offset popper by the |
@mattnolting Would the gap class be a |
@kmcfaul looks like you could either remove the inline styles popper is applying (which looks easiest and would avoid conflicting styles) or you could follow the core model |
512d9e7
to
de56a76
Compare
de56a76
to
470f389
Compare
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.
LPTM! Fantastic work, @kmcfaul, love this enhancement 👍
@nicolethoen I'm not sure what's going on with the codesandbox on the preview - it looks like its not actually using the PR code for it. On the surge, you'll see that the expandable-content section doesn't exist when the toggle group is closed (whereas previously it would always exist, and still does on the codesandbox). |
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.
Looks great! I do think an integration test for this bug would be nice, as would unit tests for the new props, but I won't block over it.
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.
LGTM, Thanks!
What: Closes #7590
First pass on multiple toggle groups.
Multiple toggle groups (and filter chip groups in different toggle groups) will work separately but currently share a container portal (as in toggling will add/subtract from the same container). I'm experimenting with replacing portal contents, or using separate portals. Unless a single portal will work, WDYT? @nicolethoen
Overall the current approach requires manual management of the expanded state, and requires passing that expanded state logic to multiple components (
ToolbarContent
,ToolbarToggleGroup
,ToolbarFilter
) to bypass internal logic which only supports a single toggle group. There is a temp example up on the Toolbar doc page that I'll remove before merging which showcases it.