-
Notifications
You must be signed in to change notification settings - Fork 840
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
Document EuiAccordion disabled state #6088
Conversation
dd22055
to
5a1b4a1
Compare
playground: accordionConfig, | ||
props: { EuiAccordion }, | ||
snippet: `<EuiAccordion |
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'd also appreciate guidance on what to do with these properties ln 451-453. 🙇
Preview documentation changes for this PR: https://eui.elastic.co/pr_6088/ |
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 added a comment for screen reader user case. LMK if you'd like to discuss further!
<div> | ||
<EuiAccordion | ||
id={disabledAccordionId} | ||
buttonContent="Security settings" |
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'd like to see this buttonContent
prop expanded to include a conditional EuiScreenReaderOnly
component that further explains the disabled state. If I'm using a screen reader and listening to the Form Controls menu, I'm not going to have any of the error state context. The only thing I will hear is the label "Security settings, dimmed button."
This signals the button is there, but not why it's dimmed. A better message might be "Security settings has errors in expanded content. dimmed button." This isn't exact wording, but a for instance.
The EUI docs show buttonContent
as a React Node, so you should be able to do something like the following snippet, assuming a new prop isDisabled
:
+ const disabledButtonContent =
+ <>
+ <span>Security settings</span>
+ <EuiScreenReaderOnly>
+ <span>{' '}has errors in expanded content.</span>
+ </EuiScreenReaderOnly>
+ </>;
- buttonContent="Security settings"
+ buttonContent={isDisabled ? disabledButtonContent : "Security settings"}
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.
@1Copenut If we were to build isDisabled
directly into EuiAccordion, do you have any other advice we should be requiring of the consumer for the disabled state?
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.
Off the top of my head the only other recommendation would be to only use isDisabled
with Accordions that render a button on the page. Having a disabled
attribute on a fieldset will thrown an error in axe (linter, unit tests, et al.)
@cjcenizal While you are correct that it's possible to create a Without adding some more complex TS to that prop and then having consumers have to create such a complicated setup, we should just support it at the top level. I'll take a quick look at this PR locally as a starting point since you've already created the docs section 🙇♀️ . |
Closing in favor of #6095 |
Summary
I'm anticipating the need to disable an accordion in elastic/kibana#137464 and found that this state seems to be supported by the existing props, but isn't documented. I added some documentation for this state and would love some guidance on whether this is indeed supported with the existing props, and if so how to improve the docs for it.
There are a couple weird things about this state that makes me suspect we didn't intend to support it originally.
Incomplete hover state. The hover state for the
.euiAccordionForm__button
class doesn't take into account a disabled state, so even though you can't click it, it still looks clickable when you hover.TS errors. There are TS errors when I pass
arrowProps
andbuttonProps
like this:arrowProps
error:buttonProps
error:Checklist
Checked in Chrome, Safari, Edge, and FirefoxProps have proper autodocs and playground togglesChecked Code Sandbox works for any docs examplesAdded or updated jest and cypress testsChecked for breaking changes and labeled appropriatelyChecked for accessibility including keyboard-only and screenreader modesUpdated the Figma library counterpartA changelog entry exists and is marked appropriately