-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
lib: Support headers with TypeaheadSelect #21183
lib: Support headers with TypeaheadSelect #21183
Conversation
mvollmer
commented
Oct 29, 2024
•
edited
Loading
edited
- lib: Introduce our own TypeaheadSelect and use it everywhere #21175
- tests for the new TypeaheadSelect in general
- Allow dividers before headers and treat them right during filtering
866b34b
to
5f5a440
Compare
a94ee95
to
018531b
Compare
018531b
to
5b6e088
Compare
ccbfbe7
to
ca76a3f
Compare
0ba70a1
to
79104d7
Compare
79104d7
to
16d2e4f
Compare
@garrett, I need your design input for how the headers should look. PF5 headers look like this: |
edd2893
to
eccba0c
Compare
eccba0c
to
308138d
Compare
Yes, that's how PF5 headers look.
|
I'm looking ahead to PF6 to see what they now think headings (not headers) look like... They have some issues in PF6. 🤨 So I think we'll probably need custom stuff when we upgrade to PF6 anyway. I did find this in the design for the non-form selects, but it's from PF5: From https://www.patternfly.org/components/menus/select/design-guidelines#select-lists-with-favorites But then they also have grouped items and I didn't even notice that it had headings, until I hovered over it... https://www.patternfly.org/components/menus/select#with-grouped-items But they have other style problems too, like super-low contrast for disabled items and not found messages: |
After looking at everything in both PF5 and PF6:
Since we want to use headings and description text in #1872, I think we need dividers between the sections on by default. (Perhaps with a way to turn them off if we don't have description text.) |
OK, so TL;DR from the above, focusing on what we need to do: For now, in this PR:
For the future, outside of this PR:
|
Roger! |
360522a
to
a00705d
Compare
a00705d
to
56960e1
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.
Thanks! A grab-bag of questions and minor ignorable stuff, but I think at least the dark mode should be fixed.
Thanks for the review! This is indeed from my very early days of TypeScript exposure, and I really should go back and make it more solid. For example, I'll try to encode in the types that dividers and headers are different animals than regular items. They don't have isDisabled, for example, and will need a key property. |
56960e1
to
98b5897
Compare
67bf149
to
0724681
Compare
0724681
to
44ea1e1
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.
👏 Thanks!
export interface TypeaheadSelectDividerOption { | ||
decorator: "divider"; |
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.
This is really cool!
import { Checkbox } from '@patternfly/react-core'; | ||
import { TypeaheadSelect, TypeaheadSelectOption } from "cockpit-components-typeahead-select"; | ||
|
||
const TypeaheadDemo = ({ options } : { options: TypeaheadSelectOption[] }) => { |
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'm really amazed that you could fully type this without too much effort. Makes the "type ahead demo" twice as interesting! 😉
|
||
|
||
@testlib.nondestructive | ||
class TestLib(testlib.MachineCase): |
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.
Hmm, the others are in check-pages, but not that important.
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.
Yeah, I thought I start a new pattern for cockpit-component tests. I was always surprised to find them in check-pages.
) => { | ||
onSelect && onSelect(_event, option.value); | ||
closeMenu(); | ||
}; | ||
|
||
const _onSelect = (_event: React.MouseEvent<Element, MouseEvent> | undefined, value: string | number | undefined) => { | ||
if (value && value !== NO_RESULTS) { | ||
const optionToSelect = selectOptions.find((option) => option.value === value); | ||
const optionToSelect = selectOptions.find((option) => isMenu(option) && option.value === value) as TypeaheadSelectMenuOption | undefined; |
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.
This could be better written as guard function.
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.
Done.
This also changes the way dividers are encoded, so that TypeScript can better understand the option variants.
44ea1e1
to
68ac285
Compare