Skip to content

Conversation

@kmcfaul
Copy link
Contributor

@kmcfaul kmcfaul commented Apr 24, 2023

What: Closes #8874

Updates examples in Select:

  • adds disabled state checkbox to basic example
  • adds divider to select group

Adds examples to Select:

  • option variation example
  • view more example
  • creatable typeahead example
  • creatable multitypeahead example
  • checkbox multitypeahead example

Other changes:

  • Adds footer example to menu examples.
  • Adds blurb over props pointing to Menu documentation for additional props, and adds commonly used props directly to the Select props.
  • Adds an interface that includes commonly used popper props for select and included the interface in the docs.
  • Fixes a description spelling mistake in menu.
  • Forwards ref through SelectOption to enable view more

Addressing #8985

  • Fixes the toggle focus with Esc/Tab - added a preventDefault that was interfering with Tab
  • Adds toggle ref to the selection callback to allow a user to focus the toggle after a selection (since the toggle ref is not controlled or set by the user). Alternately, if having the callback param isn't desired I could swap to a shouldCloseOnSelect flag that triggers the focusing internally

Notes:

  • ARIA disabled styling is not present on menu currently, so that variation was not included on the option variation example. I have a local stash adding an isAriaDisabled flag similar to other components that include the prop, but the style modifier doesn't exist on menu.
  • As the default behavior of Select is to have tab close the menu, the "menu with footer" example was added to the custom menus page instead so the tab behavior can be controlled.

@patternfly-build
Copy link
Contributor

patternfly-build commented Apr 24, 2023

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.

@kmcfaul this is looking good. Just a couple of issues/questions:

  • One small doc update request.
  • The "Typeahead with creatable options" does not seem to be working correctly. If I use this to add another state to the menu, it becomes selected in the toggle, but opening the menu again does not show me all states, I need to clear the selection to get this. Once an item is selected, shouldn't is go back to displaying the entire list? Isn't this the way the old example worked?
  • I see that you added the "With footer" example to the custom menu demos. Why? I think that the desire to have an example is Select was to make sure consumers don't think that feature was dropped.


```

### Option variations
Copy link
Member

Choose a reason for hiding this comment

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

Can we call this something more descriptive like, "Menu item variants" or just add some descriptive text to say what this is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure I will update the description.

For the other feedback:

  • Both single typeaheads behave this way currently, but I can update them to stop filtering after a selection (currently the examples use the input value to do filtering - the filter value just needs to be tracked in a separate state).
  • I added it there because Select's built-in tab behavior is incompatible with the example (tab needs to have its default behavior rather than close the select). Since this PR I updated Dropdown/Menu to allow customization of those closing keys, so I can add that update here as well and move it back into Select.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other reason for adding the demo to custom menus was because things like MenuSearch and MenuFooter lay outside the MenuContent, but in Select and Dropdown the MenuContent is internal so the extra children would be under the content instead of outside it. I think this is only a DOM difference though, without affecting keyboard or visual behavior.

@nicolethoen
Copy link
Contributor

  • ARIA disabled styling is not present on menu currently, so that variation was not included on the option variation example. I have a local stash adding an isAriaDisabled flag similar to other components that include the prop, but the style modifier doesn't exist on menu.

Sounds like this should be a post v5 core issue? Could you open one?

@kmcfaul kmcfaul force-pushed the select-next-examples branch from 647d5e2 to 6664793 Compare May 3, 2023 17:56
@kmcfaul
Copy link
Contributor Author

kmcfaul commented May 3, 2023

@nicolethoen Opened patternfly/patternfly#5528 to track the aria-disabled styling.

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

Recent updates look good, just had two other things below

@kmcfaul kmcfaul force-pushed the select-next-examples branch from d80720d to 7821279 Compare May 8, 2023 15:00
@kmcfaul kmcfaul force-pushed the select-next-examples branch from a9dccb3 to 37e259f Compare May 9, 2023 15:03
@nicolethoen nicolethoen requested a review from mcarrano May 9, 2023 20:38
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.

@kmcfaul this looks good. Just one other small ask. Can we change the style of the button in the Footer example to a plain link-style button? While it's not really relevant from a coding standpoint, I don't think we'd want to use a primary button like this in a menu footer and people do take these examples very literal. So it should look like the below. Thanks!

Screenshot 2023-05-10 at 9 33 44 AM

@kmcfaul kmcfaul force-pushed the select-next-examples branch from 7383df1 to 58aeae5 Compare May 11, 2023 17:24
@nicolethoen nicolethoen requested a review from mcarrano May 11, 2023 20:02
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.

Looks great. Thanks @kmcfaul !

Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

Something seems to have regressed with the checkbox select spacing.
cc @mcoker

image

Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

A general comment for the select examples. I think the should be updated to to use the internally generated menuRef ref rather than the consumer passing a ref. I don't want the consumers to think the have to pass the ref.

onSelect?: (
event?: React.MouseEvent<Element, MouseEvent>,
itemId?: string | number,
toggleRef?: React.RefObject<any>
Copy link
Contributor

Choose a reason for hiding this comment

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

So the whole purpose of having the toggle render is so that consumer does not have to pass a ref. I think we should not expect the consumer to use the ref in this way. I would opt for the shouldCloseOnSelect prop instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ref looks like it was a holdover from when we manually wired everything up and wasn't currently being used so I removed them.

I added a shouldFocusToggleOnSelect prop (the ref is only for that purpose as opening/closing is entirely user-side). However, the "view more" example will break with this change because it should not be focusing the toggle when the selection is the loading option, so I've left the optional property in for now and added comments to the specific example and description of the callback. Will that work?

Or alternately we could add an optional toggleRef parameter (similar to how ref is optional and without anything passed it will default to an internal ref) and let toggle accept a node as well as a function to allow a user to control the toggleRef completely. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

@thatblindgeye @nicolethoen which approach do you think is more intuitive? I m leaning towards the first approach but i can see benefits of the second as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd agree that either approach could work. I might lean more towards the toggleRef prop approach personally as it offers that flexibility and isn't tied to just onSelect being called, but considering we're mainly trying to focus the toggle "on select" I'd be fine with the PR as it is.

Just a couple of things:

  • Will this require Dropdown to be updated similarly?
  • For the prop description on onSelect and shouldFocusToggleOnSelect, maybe adding in some verbiage to explain that one or the other should be used and not both.

Copy link
Contributor Author

@kmcfaul kmcfaul May 17, 2023

Choose a reason for hiding this comment

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

Pushed an update with the alternate method, which I can back out if necessary. I kind of like the fallback being manual control of the toggleRef instead of the callback because then a user can control focus in other circumstances as well, not just selection. The view more example showcases the new method.

Also updated Dropdown similarly.

@kmcfaul kmcfaul force-pushed the select-next-examples branch from 58aeae5 to 884ced5 Compare May 16, 2023 14:28
@tlabaj
Copy link
Contributor

tlabaj commented May 16, 2023

Something seems to have regressed with the checkbox select spacing. cc @mcoker

@kmcfaul @mcoker I am opened a issue #9128 against the React menu for this one. They issue doe not see, to exist in core.

@kmcfaul kmcfaul force-pushed the select-next-examples branch from c02ceb3 to 644cbaf Compare May 17, 2023 20:38
@kmcfaul kmcfaul force-pushed the select-next-examples branch from 644cbaf to 8ab9226 Compare May 17, 2023 21:31
Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

Thanks for the updates! LGTM

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

Also have the same question as Nicole above

@thatblindgeye thatblindgeye merged commit 4b296dd into patternfly:v5 May 18, 2023
@patternfly-build
Copy link
Contributor

Your changes have been released in:

  • @patternfly/react-code-editor@5.0.0-alpha.109
  • @patternfly/react-core@5.0.0-alpha.108
  • @patternfly/react-docs@6.0.0-alpha.116
  • demo-app-ts@5.0.0-alpha.92
  • @patternfly/react-table@5.0.0-alpha.110

Thanks for your contribution! 🎉

gildub pushed a commit to konveyor/tackle2-ui that referenced this pull request Jul 17, 2023
…ecated `DropdownItems`, use `isAriaDisabled` prop for items with tooltips (#1150)

Fixes a regression caused by #1126 where dropdown items that are
disabled with tooltips could not trigger the tooltips. Discovered by
@gildub when working on #1149.

It appears the `isAriaDisabled` prop which we need for retaining the
mouse hover event on a disabled DropdownItem is not present in the new
PF5 DropdownItem. This is due to missing styles in PF core that are
still being addressed (see
patternfly/patternfly#5528,
patternfly/patternfly#5692, and related comment
here:
patternfly/patternfly-react#8992 (comment))

Until `isAriaDisabled` is supported in the new PF5 DropdownItem we must
restore the usage of the deprecated component for these tooltips to
work.
nicolethoen pushed a commit to Kells512/patternfly-react that referenced this pull request Sep 1, 2023
…ly#8992)

* feat(Select): add examples, add popper interface, fix focus

* feedback round 1

* fix component reference in docs

* remove unneeded toggle focus

* remove popperprops extension, add beta to keys

* remove container

* update snap for removal of container div

* update button

* remove unneeded ref, add focus flag & comments

* toggleRef option

* update dropdown examples

* snap

* update desc

* update wording

* use single prop

* move toggle object to interface, add to docs

* prop req and remove extra prop
sshveta pushed a commit to sshveta/tackle2-ui that referenced this pull request Oct 31, 2025
…ecated `DropdownItems`, use `isAriaDisabled` prop for items with tooltips (konveyor#1150)

Fixes a regression caused by konveyor#1126 where dropdown items that are
disabled with tooltips could not trigger the tooltips. Discovered by
@gildub when working on konveyor#1149.

It appears the `isAriaDisabled` prop which we need for retaining the
mouse hover event on a disabled DropdownItem is not present in the new
PF5 DropdownItem. This is due to missing styles in PF core that are
still being addressed (see
patternfly/patternfly#5528,
patternfly/patternfly#5692, and related comment
here:
patternfly/patternfly-react#8992 (comment))

Until `isAriaDisabled` is supported in the new PF5 DropdownItem we must
restore the usage of the deprecated component for these tooltips to
work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Select - enhance the examples available on the newly promoted Select Next implementation

7 participants