-
Notifications
You must be signed in to change notification settings - Fork 861
feat(eslint-plugin): add new @elastic/eui/callout-announce-on-mount rule
#9005
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
feat(eslint-plugin): add new @elastic/eui/callout-announce-on-mount rule
#9005
Conversation
@elastic/eui/callout-announce-on-mount rule
| schema: [], | ||
| messages: { | ||
| missingAnnounceOnMount: [ | ||
| 'EuiCallout should have "announceOnMount" prop when conditionally rendered for better accessibility.', |
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.
please replace EuiCallout -> CALLOUT_COMPONENT (for all places) + in description
| }; | ||
| }, | ||
| meta: { | ||
| type: 'suggestion', |
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.
let's set problem?
| return; | ||
| } | ||
| if (isInConditionalRendering(node)) { | ||
| const hasSpread = openingElement.attributes.some(a => a.type === 'JSXSpreadAttribute'); |
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.
can we reuse packages/eslint-plugin/src/utils/has_spread.ts
|
|
||
| export const CallOutAnnounceOnMount = ESLintUtils.RuleCreator.withoutDocs({ | ||
| create(context) { | ||
| function isInConditionalRendering(node: TSESTree.JSXElement): boolean { |
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.
candidate for moving into packages/eslint-plugin/src/utils/
Co-authored-by: Weronika Olejniczak <32842468+weronikaolejniczak@users.noreply.github.com>
💚 Build SucceededHistory
|
💚 Build Succeeded
History
|
weronikaolejniczak
left a comment
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.
LGTM 🟢 Thanks for contributing @paulinashakirova! 🥳
- `@elastic/eui`: `v106.5.0` ⏩ `v106.6.0` - `@elastic/eui-theme-borealis`: `v3.3.2` ⏩ `v3.4.0` - `@elastic/eslint-plugin-eui`: `v2.3.0` ⏩ `v2.4.0` [Questions? Please see our Kibana upgrade FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams) ## Package updates ### `@elastic/eui` #### [`v106.6.0`](https://github.com/elastic/eui/releases/v106.6.0) **Accessibility** - Removed focus state styles for `iconOnClick` on `EuiBadge` to improve color contrast in dark mode ([#9004](elastic/eui#9004)) ### `@elastic/eui-theme-borealis` #### [`v3.4.0`](https://www.npmjs.com/package/@elastic/eui-theme-borealis/v/3.4.0) - Updated values for component tokens ([#8983](elastic/eui#8983)) - `dataGridRowStripesBackgroundHover` - `dataGridRowStripesBackgroundStripedHover` - `dataGridRowStripesBackgroundSelectHover` - `dataGridRowStripesBackgroundHover` - `dataGridRowStripesBackgroundStripedHover` ### `@elastic/eslint-plugin-eui` #### [`v2.4.0`](https://www.npmjs.com/package/@elastic/eslint-plugin-eui/v/2.4.0) - Added new `callout-announce-on-mount` rule. ([#9005](elastic/eui#9005)) - Added new `no-unnamed-interactive-element` rule. ([#8973](elastic/eui#8973))
- `@elastic/eui`: `v106.5.0` ⏩ `v106.6.0` - `@elastic/eui-theme-borealis`: `v3.3.2` ⏩ `v3.4.0` - `@elastic/eslint-plugin-eui`: `v2.3.0` ⏩ `v2.4.0` [Questions? Please see our Kibana upgrade FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams) ## Package updates ### `@elastic/eui` #### [`v106.6.0`](https://github.com/elastic/eui/releases/v106.6.0) **Accessibility** - Removed focus state styles for `iconOnClick` on `EuiBadge` to improve color contrast in dark mode ([elastic#9004](elastic/eui#9004)) ### `@elastic/eui-theme-borealis` #### [`v3.4.0`](https://www.npmjs.com/package/@elastic/eui-theme-borealis/v/3.4.0) - Updated values for component tokens ([elastic#8983](elastic/eui#8983)) - `dataGridRowStripesBackgroundHover` - `dataGridRowStripesBackgroundStripedHover` - `dataGridRowStripesBackgroundSelectHover` - `dataGridRowStripesBackgroundHover` - `dataGridRowStripesBackgroundStripedHover` ### `@elastic/eslint-plugin-eui` #### [`v2.4.0`](https://www.npmjs.com/package/@elastic/eslint-plugin-eui/v/2.4.0) - Added new `callout-announce-on-mount` rule. ([elastic#9005](elastic/eui#9005)) - Added new `no-unnamed-interactive-element` rule. ([elastic#8973](elastic/eui#8973))
- `@elastic/eui`: `v106.5.0` ⏩ `v106.6.0` - `@elastic/eui-theme-borealis`: `v3.3.2` ⏩ `v3.4.0` - `@elastic/eslint-plugin-eui`: `v2.3.0` ⏩ `v2.4.0` [Questions? Please see our Kibana upgrade FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams) ## Package updates ### `@elastic/eui` #### [`v106.6.0`](https://github.com/elastic/eui/releases/v106.6.0) **Accessibility** - Removed focus state styles for `iconOnClick` on `EuiBadge` to improve color contrast in dark mode ([#9004](elastic/eui#9004)) ### `@elastic/eui-theme-borealis` #### [`v3.4.0`](https://www.npmjs.com/package/@elastic/eui-theme-borealis/v/3.4.0) - Updated values for component tokens ([#8983](elastic/eui#8983)) - `dataGridRowStripesBackgroundHover` - `dataGridRowStripesBackgroundStripedHover` - `dataGridRowStripesBackgroundSelectHover` - `dataGridRowStripesBackgroundHover` - `dataGridRowStripesBackgroundStripedHover` ### `@elastic/eslint-plugin-eui` #### [`v2.4.0`](https://www.npmjs.com/package/@elastic/eslint-plugin-eui/v/2.4.0) - Added new `callout-announce-on-mount` rule. ([#9005](elastic/eui#9005)) - Added new `no-unnamed-interactive-element` rule. ([#8973](elastic/eui#8973))
- `@elastic/eui`: `v106.5.0` ⏩ `v106.6.0` - `@elastic/eui-theme-borealis`: `v3.3.2` ⏩ `v3.4.0` - `@elastic/eslint-plugin-eui`: `v2.3.0` ⏩ `v2.4.0` [Questions? Please see our Kibana upgrade FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams) ## Package updates ### `@elastic/eui` #### [`v106.6.0`](https://github.com/elastic/eui/releases/v106.6.0) **Accessibility** - Removed focus state styles for `iconOnClick` on `EuiBadge` to improve color contrast in dark mode ([elastic#9004](elastic/eui#9004)) ### `@elastic/eui-theme-borealis` #### [`v3.4.0`](https://www.npmjs.com/package/@elastic/eui-theme-borealis/v/3.4.0) - Updated values for component tokens ([elastic#8983](elastic/eui#8983)) - `dataGridRowStripesBackgroundHover` - `dataGridRowStripesBackgroundStripedHover` - `dataGridRowStripesBackgroundSelectHover` - `dataGridRowStripesBackgroundHover` - `dataGridRowStripesBackgroundStripedHover` ### `@elastic/eslint-plugin-eui` #### [`v2.4.0`](https://www.npmjs.com/package/@elastic/eslint-plugin-eui/v/2.4.0) - Added new `callout-announce-on-mount` rule. ([elastic#9005](elastic/eui#9005)) - Added new `no-unnamed-interactive-element` rule. ([elastic#8973](elastic/eui#8973))
…ceOnMount` in conditional rendered instances (#235054) ## Summary This PR introduces fix for our new eslint rule [`@elastic/eui/callout-announce-on-mount`](elastic/eui#9005). ### Problem tldr; When callouts appear dynamically (e.g., after user interactions, form validation errors, or status changes), screen readers may not announce their content to users. The `announceOnMount` prop ensures these messages are properly announced to users with assistive technologies. #### Please double check your code - to make sure that if `EuiCallout` appears dynamically after a user interaction, the `announceOnMount` is NOT set to false. I did my best, but might have missed some because of my lacking context. > [!NOTE] > If `EuiCallOut` is inside a condition, announceOnMount must be set explicitly. --------- Co-authored-by: Robert Jaszczurek <92210485+rbrtj@users.noreply.github.com> Co-authored-by: Davis McPhee <davismcphee@hotmail.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com>
…ceOnMount` in conditional rendered instances (elastic#235054) ## Summary This PR introduces fix for our new eslint rule [`@elastic/eui/callout-announce-on-mount`](elastic/eui#9005). ### Problem tldr; When callouts appear dynamically (e.g., after user interactions, form validation errors, or status changes), screen readers may not announce their content to users. The `announceOnMount` prop ensures these messages are properly announced to users with assistive technologies. #### Please double check your code - to make sure that if `EuiCallout` appears dynamically after a user interaction, the `announceOnMount` is NOT set to false. I did my best, but might have missed some because of my lacking context. > [!NOTE] > If `EuiCallOut` is inside a condition, announceOnMount must be set explicitly. --------- Co-authored-by: Robert Jaszczurek <92210485+rbrtj@users.noreply.github.com> Co-authored-by: Davis McPhee <davismcphee@hotmail.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com>
…ceOnMount` in conditional rendered instances (elastic#235054) ## Summary This PR introduces fix for our new eslint rule [`@elastic/eui/callout-announce-on-mount`](elastic/eui#9005). ### Problem tldr; When callouts appear dynamically (e.g., after user interactions, form validation errors, or status changes), screen readers may not announce their content to users. The `announceOnMount` prop ensures these messages are properly announced to users with assistive technologies. #### Please double check your code - to make sure that if `EuiCallout` appears dynamically after a user interaction, the `announceOnMount` is NOT set to false. I did my best, but might have missed some because of my lacking context. > [!NOTE] > If `EuiCallOut` is inside a condition, announceOnMount must be set explicitly. --------- Co-authored-by: Robert Jaszczurek <92210485+rbrtj@users.noreply.github.com> Co-authored-by: Davis McPhee <davismcphee@hotmail.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Vitalii Dmyterko <92328789+vitaliidm@users.noreply.github.com>
Summary
This PR introduces a new ESLint rule
@elastic/eui/callout-announce-on-mountProblem
When callouts appear dynamically (e.g., after user interactions, form validation errors, or status changes), screen readers may not announce their content to users.
The
announceOnMountprop ensures these messages are properly announced to users with assistive technologies.Screen.Recording.2025-09-10.at.21.22.15.mov