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

lib: Support headers with TypeaheadSelect #21183

Merged
merged 4 commits into from
Nov 26, 2024

Conversation

mvollmer
Copy link
Member

@mvollmer mvollmer commented Oct 29, 2024

image

@mvollmer mvollmer force-pushed the lib-typeahead-select-groups branch 2 times, most recently from 866b34b to 5f5a440 Compare October 29, 2024 12:15
@mvollmer mvollmer added the no-test For doc/workflow changes, or experiments which don't need a full CI run, label Oct 31, 2024
@mvollmer mvollmer force-pushed the lib-typeahead-select-groups branch 3 times, most recently from a94ee95 to 018531b Compare October 31, 2024 13:15
test/verify/check-lib-typeahead Fixed Show fixed Hide fixed
test/verify/check-lib-typeahead Fixed Show fixed Hide fixed
test/verify/check-lib-typeahead Fixed Show fixed Hide fixed
test/verify/check-lib-typeahead Fixed Show fixed Hide fixed
test/verify/check-lib-typeahead Fixed Show fixed Hide fixed
test/verify/check-lib-typeahead Fixed Show fixed Hide fixed
test/verify/check-lib-typeahead Fixed Show fixed Hide fixed
test/verify/check-lib-typeahead Fixed Show fixed Hide fixed
@mvollmer mvollmer force-pushed the lib-typeahead-select-groups branch 3 times, most recently from ccbfbe7 to ca76a3f Compare November 12, 2024 10:13
test/verify/check-lib Fixed Show fixed Hide fixed
@mvollmer mvollmer force-pushed the lib-typeahead-select-groups branch 2 times, most recently from 0ba70a1 to 79104d7 Compare November 12, 2024 12:27
@mvollmer mvollmer removed the no-test For doc/workflow changes, or experiments which don't need a full CI run, label Nov 12, 2024
@mvollmer
Copy link
Member Author

@garrett, I need your design input for how the headers should look.

PF5 headers look like this:

image

@mvollmer mvollmer marked this pull request as ready for review November 12, 2024 13:40
@mvollmer mvollmer force-pushed the lib-typeahead-select-groups branch 5 times, most recently from edd2893 to eccba0c Compare November 13, 2024 09:01
@mvollmer mvollmer added the no-test For doc/workflow changes, or experiments which don't need a full CI run, label Nov 13, 2024
@mvollmer mvollmer added no-test For doc/workflow changes, or experiments which don't need a full CI run, and removed no-test For doc/workflow changes, or experiments which don't need a full CI run, labels Nov 13, 2024
@garrett
Copy link
Member

garrett commented Nov 13, 2024

@garrett, I need your design input for how the headers should look.

PF5 headers look like this:

Yes, that's how PF5 headers look.

  1. What are you looking for specifically? I'm not sure what you're asking.
  2. How would I check this out to verify that it looks like PF5? (Like, which page, modal, widget?) I've poked around after building the branch and it's not clear what I should be looking at.

@garrett
Copy link
Member

garrett commented Nov 18, 2024

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:

image

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...

image

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:

image

image

@garrett
Copy link
Member

garrett commented Nov 18, 2024

After looking at everything in both PF5 and PF6:

  1. Headings should be styled differently from entry items. (PF6 is technically using a slightly different color, but it's not obvious at all. The font size and/or weight needs to change too; otherwise it's just too subtle.)
  2. The light color for disabled and error messages in PF6 is not AA contrast compliant, and probably cant even be read on cheaper displays or in bright environments. Even under ideal conditions, many people won't be able to read it, and it can even cause eyestrain to those who can.
    image
  3. All the examples I've found from PF5 and PF6 use separators between groups, in addition to the headings. Headings alone are not enough, especially if there is description text.

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.)

@garrett
Copy link
Member

garrett commented Nov 18, 2024

OK, so TL;DR from the above, focusing on what we need to do:

For now, in this PR:

  1. Specifically thinking of create: Show all operating systems cockpit-machines#1872, make sure there are dividers between sections, probably on by default. They should definitely be present when there are descriptions. (It could alternative be automatically on if descriptions exist. Or just always on.)

For the future, outside of this PR:

  1. When we upgrade to PF6, I think we'll either need to customize things in our widget and/or have some CSS overrides to fix their issues.
  2. We need to file some upstream issues with PF6 problems. (Contrast problems, spacing problems, size issues as the headers are currently indistinguishable, etc.) I've communicated all this before a few times with PF6 during the pre-alpha and alpha phases, but now that it's released and still has many of the the same problems I reported multiple times, I need to file specific bugs to have them fixed and we'll probably need local overrides still, as it'll be unclear as to when they'll fix these actual quantifiable UI, UX, and accessibility problems.

@mvollmer
Copy link
Member Author

  1. make sure there are dividers between sections, probably on by default.

Roger!

@mvollmer mvollmer force-pushed the lib-typeahead-select-groups branch 3 times, most recently from 360522a to a00705d Compare November 19, 2024 14:13
@mvollmer mvollmer removed the no-test For doc/workflow changes, or experiments which don't need a full CI run, label Nov 19, 2024
Copy link
Member

@martinpitt martinpitt left a 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.

pkg/lib/cockpit-components-typeahead-select.tsx Outdated Show resolved Hide resolved
pkg/lib/cockpit-components-typeahead-select.tsx Outdated Show resolved Hide resolved
pkg/lib/cockpit-components-typeahead-select.tsx Outdated Show resolved Hide resolved
pkg/lib/cockpit-components-typeahead-select.tsx Outdated Show resolved Hide resolved
pkg/playground/react-demo-typeahead.jsx Outdated Show resolved Hide resolved
pkg/playground/react-demo-typeahead.jsx Outdated Show resolved Hide resolved
test/verify/check-lib Show resolved Hide resolved
@mvollmer
Copy link
Member Author

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.

@mvollmer mvollmer added the no-test For doc/workflow changes, or experiments which don't need a full CI run, label Nov 22, 2024
@mvollmer mvollmer force-pushed the lib-typeahead-select-groups branch 2 times, most recently from 67bf149 to 0724681 Compare November 22, 2024 14:57
@mvollmer mvollmer removed the no-test For doc/workflow changes, or experiments which don't need a full CI run, label Nov 22, 2024
martinpitt
martinpitt previously approved these changes Nov 22, 2024
Copy link
Member

@martinpitt martinpitt left a comment

Choose a reason for hiding this comment

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

👏 Thanks!

Comment on lines +105 to +106
export interface TypeaheadSelectDividerOption {
decorator: "divider";
Copy link
Member

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[] }) => {
Copy link
Member

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):
Copy link
Member

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.

Copy link
Member Author

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;
Copy link
Member Author

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.

Copy link
Member Author

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.
@mvollmer mvollmer merged commit 8d9f97b into cockpit-project:main Nov 26, 2024
83 of 85 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants