Skip to content
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

chore(Dropdown): updated deprecated usage to new dropdown #8868

Merged
merged 22 commits into from
May 3, 2023

Conversation

thatblindgeye
Copy link
Contributor

@thatblindgeye thatblindgeye commented Mar 27, 2023

What: Closes #8839

Pages from the surge that were updated (some with notes, other notes after this list):

Other notes:

  • Demos that use selectable cards + action kebabs (Card view, primary details, etc): clicking the kebab causes the cards' selection to occur
  • Looks like the wrapper div that is rendered around Dropdown's Popper prevents MenuToggle from being full height when isFullHeight is passed (we may not need that wrapper anymore since moving forward we're defaulting to an "inline" appendTo, which that wrapper div was just to give the Popper something to append to)
  • The new Dropdown inside of PageHeader components (non-Masthead) doesn't have the correct styling
Original comment regarding badge toggle

Wanted to put a draft up to get some opinion on the Menu Toggle with badge implementation (seen in the Breadcrumb with dropdown example here).

With the deprecated Dropdown, there was a separate BadgeToggle sub-component that was used, but MenuToggle doesn't have that. What I did for now in this PR is just pass Badge component as a child to MenuToggle (rather than using the badge prop), and set it to a plainText variant. I figured right now that would be the simplest way to show how a consumer could use this new composable implementation.

Alternatively we could maybe implement a new prop in MenuToggle that would create a "BadgeToggle", but one possible issue is whether that would get confusing since we already have an icon and badge prop on MenuToggle. Some ideas:

  • Introduce a new "badge" variant, along with "plain", "default", etc. that would set the markup and styling similar to how BadgeToggle did
  • Add a new prop (isBadgeToggle?) that would probably do the same as above
  • Show how to use the menu classes to create a custom badge toggle, basically leave it up to the consumer (probably not great since it'd involve hardcoding classes in?)

There may need some Core followup as I did notice the breadcrumb items with a dropdown weren't centered right. Changing the .pf-c-breadcrumb__item "align-items" property to center instead of baseline may help, but I haven't looked into whether that would cause any other issues.

Additional issues:

@patternfly-build
Copy link
Contributor

patternfly-build commented Mar 27, 2023

@mcarrano
Copy link
Member

@mceledonia @mmenestr @andrew-ronaldson would like to get your opinion on this one. See the question posed by @thatblindgeye in the description above. The gist of this is that by deprecating the old dropdown, we loose the badge variant that allows us to make a badge into a toggle. We could add that to Menu Toggle, but there's a question how useful this is. This was a feaure that was requested for condensing a long breadcrumb control. Not aware that it's used anyplace else. Here are two links where you can compare the existing vs. new implementation:

Existing: https://www.patternfly.org/v4/components/breadcrumb#with-dropdown

Updated: https://patternfly-react-pr-8868.surge.sh/components/breadcrumb#with-dropdown

Note the changed positioning of the caret. I'm OK with the updated implementation but also wanted to get your opinion. Don't recall where this is being used, but if you are aware, I can also check with that team as they may need to do some rework to update to PatternFly 5.

@thatblindgeye
Copy link
Contributor Author

@mcarrano Nicole pointed me towards a demo that has a badge toggle using MenuToggle similar to the old Dropdown BadgeToggle: composable dropdown variants

So I can actually implement that in this update, unless another approach is agreed on. From what I have seen so far, two areas where we're using a badge toggle like this in examples is the Breadcrumb example and the Menu Drilldown with breadcrumb example.

@mcarrano
Copy link
Member

mcarrano commented Apr 3, 2023

Sounds good @thatblindgeye

@thatblindgeye thatblindgeye force-pushed the iss8839_useNewDropdown branch 4 times, most recently from 3ae37c5 to 6512eaf Compare April 7, 2023 12:44
@thatblindgeye thatblindgeye marked this pull request as ready for review April 7, 2023 13:34
@tlabaj tlabaj assigned mcarrano and unassigned mcarrano Apr 12, 2023
@kmcfaul
Copy link
Contributor

kmcfaul commented Apr 12, 2023

  • Looks like the wrapper div that is rendered around Dropdown's Popper [...]

You should be able to remove the wrapping div if you pass triggerRef and popperRef to the Popper.

For the TreeView action menu, I thought the keyboard handler should prevent propagation up to the outer handler (so if the focus is in the Dropdown that handler should run and not the TreeView) but maybe that needs some tweaking.

Copy link
Member

@mcarrano mcarrano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thatblindgeye Glad you were able to work out the issue with the badge style dropdown. But I am seeing a spacing difference between this and the current implementation:

Current:
Screenshot 2023-04-12 at 4 30 50 PM

This PR:
Screenshot 2023-04-12 at 4 30 40 PM

Can that be fixed?

@thatblindgeye
Copy link
Contributor Author

thatblindgeye commented Apr 13, 2023

@mcarrano There's a couple of ways we could go about that I think:

  1. Just add some whitespace in the two examples that use this badge toggle. It looks like that's all that is supplying the spacing in the custom menus example. Would be quick and easy, leave it up to the consumer to decide how they want to style a customized badge toggle
  2. Use our Icon component to wrap the CaretIcon now, then make an update in Core to supply a padding or margin left to pf-c-icon when it's inside of pf-c-badge.

Here's what option 1 looks like with just a single space:
Badge toggle with whitespace

Here's what option 2 looks like (8px left padding on .pf-c-badge > .pf-c-icon:

Badge toggle with padding

@mcarrano
Copy link
Member

@thatblindgeye Took some time this morning to review other places affected by this change. Here are additional problems I found...

In all full page demos, the user menu is not rendering correctly. See below.

Screenshot 2023-04-13 at 9 17 19 AM

Should look like this:

Screenshot 2023-04-13 at 9 30 27 AM

I'm not entirely comfortable with effect of this on the Date & Time picker as it now feels like the time widget is no longer a part of the control.

Screenshot 2023-04-13 at 9 14 52 AM

I wonder if we'd be better off adding back the border even if it means it means we need to keep the caret.

Screenshot 2023-04-13 at 9 14 40 AM

@mmenestr @andrew-ronaldson what do you think?

@thatblindgeye
Copy link
Contributor Author

@mcarrano I should be able to resolve the user menu issue based on Katie's comment above.

Will wait for Andrew and/or Margot's input on the timepicker (can also make updates to the badge toggle depending what you think of my latest comment above)

@mcarrano
Copy link
Member

@thatblindgeye regarding fixes to the badge dropdown, I'd be OK with either approach. Although option 2 is perhaps a more robust way to do this? Maybe see what others think.

@mmenestr
Copy link
Collaborator

@mcarrano @thatblindgeye I agree it's a bit weird that the calendar icon isn't floating, but the time picker icon is. I would expect them both to be treated the same. I don't think having a dropdown styling with caret is much better, but I feel its probably a bit better than no border at all.

This is making me wonder why we created a combined date and time picker, without also creating a combined time + calendar menu to go with it... I feel like in cases where date pickers and time pickers are both needed, it would be better to use the original components side by side rather than this hybrid version which seems a bit odd. But that's a whole other issue.

@thatblindgeye
Copy link
Contributor Author

@mcarrano Made some updates to help resolve the spacing issue on the badge toggle as well as the dropdown used in full page demos for the username (should now be full height as it was before).

@mmenestr For the Timepicker, I removed the variant so that it matches the second screenshot Matt shared for now. Should we open a followup issue to resolve how we ultimately want that timepicker toggle to look?

@mcarrano
Copy link
Member

I took at look at your changes @thatblindgeye . The breadcrumb update looks good. For the Date & Time picker, can we fix this so that the clock icon does not get cut off?

@mmenestr agree about the Date & Time demo. Would you mind opening an issue to reconsider that? It's definitely beyond the scope of this PR.

@thatblindgeye
Copy link
Contributor Author

@mcarrano For the timepicker icon, it looks like it's being cut off in Firefox due to the div element in the example having a width of only 300px, so it's trying to hide the overflow with an ellipsis (I guess it doesn't work with only an icon; if you add text before the icon the menu toggle has the ellipsis like normal).

Moving that div element to only wrap the text input works, or I can pass the clock icon to the icon prop of MenuToggle which results in a little more spacing between the icon and toggle caret:

Clock icon passed to icon prop

If the spacing isn't too bad I'll push that change, since it may make more sense to pass only an icon to the icon prop.

Copy link
Member

@srambach srambach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one looks good with the follow up issues.

@tlabaj tlabaj merged commit 8c19252 into patternfly:v5 May 3, 2023
dgdavid added a commit to agama-project/agama that referenced this pull request Sep 12, 2023
dgdavid added a commit to agama-project/agama that referenced this pull request Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dropdown - update deprecated usage with new default implementation
8 participants