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

Allow inline fields with no visible label #2344

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

bryancunningham-okta
Copy link
Contributor

OKTA-687907

Summary

  • Allow some field labels to be visibly hidden

Testing & Screenshots

  • I have confirmed this change with my designer and the Odyssey Design Team.

@bryancunningham-okta bryancunningham-okta requested a review from a team as a code owner September 9, 2024 16:15
Comment on lines +90 to +94
| {
hasVisibleLabel: false;
hint?: never;
placeholder: string;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we expecting they at least pass in aria-labelledby or aria-label if they have no visible label?

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 actual label prop is still required. It's just visually hidden

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, my bad. I see. So we're just saying if the label is visible, not if it doesn't exist. My bad.

We should also require aria-labelledby if no label is passed in as an alternative. We can keep visually hiding the label, but it'd be good to say our intent is that they have to have a visual label somewhere else. That's what I mean.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

aria-labelledby will be controlled by us. It'll still be labelled by the non-visible label

Comment on lines +56 to +79
} & (
| {
/**
* If `hasVisibleLabel` is `false` it will also hide any `hint` text and `HintLinkComponent` that is passed in
*/
hasVisibleLabel?: false;
hint: never;
HintLinkComponent: never;
}
| {
/**
* defaults to `true` if `false` along with hiding the label it will also hide any `hint` text and `HintLinkComponent` that is passed in
*/
hasVisibleLabel?: true;
/**
* The helper text content.
*/
hint?: string;
/**
* A `Link` component to provide greater context that is rendered at the end of the `hint` text
*/
HintLinkComponent?: ReactElement<typeof HintLink>;
}
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible we could rewrite this type to use the function overload syntax? Or have 2 different Field components, one with a label and one that only takes aria-labelledby or something like that?

The way the code works today, it's very confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This would be a pretty significant rewrite. We'd have to refactor all the form field components(that allow a non-visible label) to handle this 'correctly'

docs: {
description: {
story:
"TextFields with `hasVisibleLabel` set to false will not render a visible label. Although, the `label` prop is still required for accessibility purposes",
Copy link
Contributor

@KevinGhadyani-Okta KevinGhadyani-Okta Sep 16, 2024

Choose a reason for hiding this comment

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

Suggested change
"TextFields with `hasVisibleLabel` set to false will not render a visible label. Although, the `label` prop is still required for accessibility purposes",
"`TextField`s with `hasVisibleLabel` set to false will not render a visible label. Although, the `label` prop is still required for accessibility purposes.",

Copy link
Contributor

Choose a reason for hiding this comment

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

There are other spots in the docs like this as well.

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