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

[EuiAccordion] Improve keyboard accessibility of tabbable children #7064

Merged
merged 6 commits into from
Aug 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/components/accordion/accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ export class EuiAccordionClass extends Component<
onToggle = () => {
const { forceState } = this.props;
if (forceState) {
this.props.onToggle &&
this.props.onToggle(forceState === 'open' ? false : true);
this.props.onToggle?.(forceState === 'open' ? false : true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice clean up!

Copy link
Member Author

@cee-chen cee-chen Aug 10, 2023

Choose a reason for hiding this comment

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

[attaching to a random comment for threading]

Seeing the getter used in accordion.tsx was a good reminder (I haven't played with class components in a while).

Just mentioning for completeness, getters can be used inside any JS object, not just inside classes! https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get

} else {
this.setState(
(prevState) => ({
Expand All @@ -170,7 +169,7 @@ export class EuiAccordionClass extends Component<
if (this.state.isOpen && this.childWrapper) {
this.childWrapper.focus();
}
this.props.onToggle && this.props.onToggle(this.state.isOpen);
this.props.onToggle?.(this.state.isOpen);
}
);
}
Expand Down