-
Notifications
You must be signed in to change notification settings - Fork 839
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
|
||
import { EuiAccordion, EuiFieldText, EuiFormRow, EuiSpacer } from '../../../../src/components'; | ||
import { useGeneratedHtmlId } from '../../../../src/services'; | ||
|
||
export default () => { | ||
const disabledAccordionId = useGeneratedHtmlId({ prefix: 'disabledAccordion' }); | ||
|
||
return ( | ||
<div> | ||
<EuiAccordion | ||
id={disabledAccordionId} | ||
buttonContent="Security settings" | ||
arrowProps={{ disabled: true }} | ||
buttonProps={{ disabled: true }} | ||
initialIsOpen={true} | ||
> | ||
<EuiSpacer size="s" /> | ||
<EuiFormRow | ||
label="Password" | ||
isInvalid={true} | ||
error={[ | ||
"You must enter your password to save these changes.", | ||
]} | ||
> | ||
<EuiFieldText name="text" isInvalid={true} /> | ||
</EuiFormRow> | ||
</EuiAccordion> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,9 @@ const accordionIsLoadingSnippet = [ | |
import AccordionButtonElement from './accordion_buttonElement'; | ||
const accordionButtonElementSource = require('!!raw-loader!./accordion_buttonElement'); | ||
|
||
import AccordionDisabled from './accordion_disabled'; | ||
const accordionDisabledSource = require('!!raw-loader!./accordion_disabled'); | ||
|
||
export const AccordionExample = { | ||
title: 'Accordion', | ||
intro: ( | ||
|
@@ -420,5 +423,40 @@ export const AccordionExample = { | |
<!-- Content to show when expanded --> | ||
</EuiAccordion>`, | ||
}, | ||
{ | ||
title: 'Disabled', | ||
source: [ | ||
{ | ||
type: GuideSectionTypes.JS, | ||
code: accordionDisabledSource, | ||
}, | ||
], | ||
text: ( | ||
<> | ||
<p> | ||
In some cases you might want to prevent the user from closing the | ||
<strong>EuiAccordion</strong>. For example, if a form field is | ||
displaying an error, opening the accordion and preventing its | ||
closure until the error has been addressed will help the user | ||
find and fix the error. | ||
</p> | ||
<p> | ||
The <EuiCode>arrowProps</EuiCode>, <EuiCode>buttonProps</EuiCode>, | ||
and <EuiCode>initialIsOpen</EuiCode> props can be used together | ||
to achieve this state. | ||
</p> | ||
</> | ||
), | ||
demo: <AccordionDisabled />, | ||
playground: accordionConfig, | ||
props: { EuiAccordion }, | ||
snippet: `<EuiAccordion | ||
Comment on lines
+451
to
+453
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. 🙇 |
||
id={accordionId1} | ||
buttonContent="Clickable title" | ||
> | ||
<!-- Content to show when expanded --> | ||
</EuiAccordion> | ||
`, | ||
}, | ||
], | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 conditionalEuiScreenReaderOnly
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 propisDisabled
: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 adisabled
attribute on a fieldset will thrown an error in axe (linter, unit tests, et al.)