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

[EuiCallOut] Add onDismiss prop #7156

Merged
merged 20 commits into from
Sep 25, 2023
Merged

[EuiCallOut] Add onDismiss prop #7156

merged 20 commits into from
Sep 25, 2023

Conversation

kyrspl
Copy link
Contributor

@kyrspl kyrspl commented Sep 5, 2023

Summary

closes #7038

Adds a cross button icon to the top right hand corner of the callout, which enables consumers to add dismissible callouts with strong accessible and design affordance.

QA

General checklist

  • Checked in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs (using @default if default values are missing) and playground toggles
  • Added documentation
  • Added or updated jest and cypress tests
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

- [ ] Checked Code Sandbox works for any docs examples
- [ ] Checked for breaking changes and labeled appropriately
- [ ] Updated the Figma library counterpart

@ryankeairns
Copy link
Contributor

Thanks @kyrspl

The refactoring raises a flag. Are you able to scale this back and remove those changes from the PR? Put another way, what is the simplest solution here?

If you feel it is absolutely necessary work, then we may consider punting on this PR and leaving it to an engineer.

@kyrspl
Copy link
Contributor Author

kyrspl commented Sep 5, 2023

Update -> Given the complexity of managing actions in the callout, we decided to reduce the scope of this PR to only render the close icon on the top right of the callout.

Any additional work for the Dismiss button should take place in a future PR.

@kyrspl kyrspl changed the title [DRAFT] Callout DRAFT [euiCallout] Add isDismissible prop Sep 7, 2023
@cee-chen cee-chen changed the title DRAFT [euiCallout] Add isDismissible prop [EuiCallOut] Add onDismiss prop Sep 23, 2023
@cee-chen cee-chen requested a review from a team as a code owner September 23, 2023 01:11
@cee-chen cee-chen force-pushed the callout branch 4 times, most recently from 08337a2 to 2525a99 Compare September 23, 2023 06:28
Switch from `close` copy to `dismiss`, which better matches other similar components (e.g. EuiToast uses `dismissToast`)
- Dismiss button should to adjust to callout size/padding

- Fix padding-right logic on top-most title or child paragraph via CSS selectors

- Fix non-working spacer logic (just use a JS conditional to render a spacer instead of CSS `:not:only-child`)

- Fix button DOM order for screen reader users

- misc `&&` vs ternary cleanup
Comment on lines +131 to +146
// Note: the DOM position of the dismiss button matters to screen reader users.
// We generally want them to have some context of _what_ they're dismissing,
// instead of navigating to the dismiss button first before the callout content
const calloutContent =
header && optionalChildren ? (
<>
{header}
{dismissButton}
<EuiSpacer size="s" />
{optionalChildren}
</>
) : (
<>
{header || optionalChildren}
{dismissButton}
</>
Copy link
Contributor

Choose a reason for hiding this comment

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

@1Copenut Would also like your thoughts on this from a screen reader UX perspective. You can test the render orders on https://eui.elastic.co/pr_7156/#/display/callout#dismissible-callouts.

My logic here was trying to keep the DOM render order as similar to the visual order as possible. This render order allows SR users to get a high level of the callout and opt to dismiss it before navigating to the child content. Do you feel that makes sense to you?

Copy link
Contributor

Choose a reason for hiding this comment

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

@cee-chen Yes I do feel this order is the best approach. It feels natural to let users hear the title, then the option to dismiss the callout or hear more information.

Eventually I'd like to move the EuiModal to use this same DOM order. Right now at least the confirm modal places the close button before the title. It was a pattern that didn't feel quite right, but didn't have a champion. Now that we're revisiting with EuiCallout, I think it's worth a second discussion.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a good point about EuiModals (and likely flyouts as well). Probably would be worth opening a separate issue about!

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. I'll open an issue now and cross-link it.

@cee-chen
Copy link
Contributor

@kyrspl As a heads up, this is almost done & I think we can get it in for next week's release, I'm just waiting to get screen reader expertise from Trevor first before merging.

Copy link
Contributor

@1Copenut 1Copenut left a comment

Choose a reason for hiding this comment

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

Left three comments, and two small suggested changes. I'll change my comment to approved after the callout accessible label is updated.

src-docs/src/views/call_out/on_dismiss.tsx Outdated Show resolved Hide resolved
src/components/call_out/call_out.tsx Outdated Show resolved Hide resolved
Comment on lines +131 to +146
// Note: the DOM position of the dismiss button matters to screen reader users.
// We generally want them to have some context of _what_ they're dismissing,
// instead of navigating to the dismiss button first before the callout content
const calloutContent =
header && optionalChildren ? (
<>
{header}
{dismissButton}
<EuiSpacer size="s" />
{optionalChildren}
</>
) : (
<>
{header || optionalChildren}
{dismissButton}
</>
Copy link
Contributor

Choose a reason for hiding this comment

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

@cee-chen Yes I do feel this order is the best approach. It feels natural to let users hear the title, then the option to dismiss the callout or hear more information.

Eventually I'd like to move the EuiModal to use this same DOM order. Right now at least the confirm modal places the close button before the title. It was a pattern that didn't feel quite right, but didn't have a champion. Now that we're revisiting with EuiCallout, I think it's worth a second discussion.

Copy link
Contributor

@1Copenut 1Copenut left a comment

Choose a reason for hiding this comment

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

👍 LGTM! Tested the inflection of "callout" in NVDA and JAWS too.

@kibanamachine
Copy link

Preview staging links for this PR:

@cee-chen cee-chen merged commit 4a83e0e into elastic:main Sep 25, 2023
1 check passed
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

jbudz pushed a commit to elastic/kibana that referenced this pull request Sep 27, 2023
`v88.3.0`⏩`v88.5.0`

closes #151514

---

## [`88.5.0`](https://github.com/elastic/eui/tree/v88.5.0)

- Updated `EuiCallOut` with a new `onDismiss` prop
([#7156](elastic/eui#7156))
- Added a new `renderCustomToolbar` prop to `EuiDataGrid`, which allows
custom rendering of the toolbar.
([#7190](elastic/eui#7190))
- Added a new `allowResetButton` prop to
`toolbarVisibility.showDisplaySelector` of `EuiDataGrid`, which allows
hiding the "Reset to default" button from the display settings popover.
([#7190](elastic/eui#7190))
- Added a new `additionalDisplaySettings` prop to
`toolbarVisibility.showDisplaySelector` of `EuiDataGrid`, which allows
rendering extra settings inside the display settings popover.
([#7190](elastic/eui#7190))
- Updated `EuiDataGrid`'s toolbar display settings button icon
([#7190](elastic/eui#7190))
- Updated `EuiTextTruncate` with significantly improved iteration
performance. Removed `measurementRenderAPI` prop, as `EuiTextTruncation`
now only uses more performant canvas render API
([#7210](elastic/eui#7210))
- Updated `EuiPopover` with a new configurable `repositionToCrossAxis`
prop ([#7211](elastic/eui#7211))
- Updated `EuiDatePicker` to support `compressed` input styling
([#7218](elastic/eui#7218))
- Added `gradient` and `palette` icon glyphs.
([#7220](elastic/eui#7220))

**Bug fixes**

- Fixed `EuiPopover`'s missing animations on popover close
([#7211](elastic/eui#7211))
- Fixed `EuiInputPopover` anchoring to the wrong side and missing
shadows on smaller screens
([#7211](elastic/eui#7211))
- Fixed `EuiSuperDatePicker` icon spacing on the quick select button
([#7217](elastic/eui#7217))
- Fixed a missing type in `EuiMarkdownEditor`'s default processing
plugins ([#7221](elastic/eui#7221))


## [`88.4.1`](https://github.com/elastic/eui/tree/v88.4.1)

**Bug fixes**

- Fixed missing `className`s on `EuiTextTruncate`
([#7212](elastic/eui#7212))
- Fixed `title`s on `EuiComboBox` dropdown options to always be present
([#7212](elastic/eui#7212))
- Fixed `EuiComboBox` truncation issues when search is an empty space
([#7212](elastic/eui#7212))

## [`88.4.0`](https://github.com/elastic/eui/tree/v88.4.0)

- Updated `EuiComboBox` to allow configuring text truncation behavior
via `truncationProps`. These props can be set on the entire combobox as
well as on on individual dropdown options.
([#7028](elastic/eui#7028))
- Updated `EuiInMemoryTable` with a new `searchFormat` prop (defaults to
`eql`). When setting this prop to `text`, the built-in search bar will
ignore EQL syntax and allow searching for plain strings with special
characters and symbols.
([#7175](elastic/eui#7175))

**Bug fixes**

- `EuiComboBox` now always shows the highlighted search text, even on
truncated text ([#7028](elastic/eui#7028))
- Fixed missing i18n in `EuiSearchBar`'s default placeholder and
aria-label text ([#7175](elastic/eui#7175))
- Fixed the inline compressed styles of `EuiDescriptionListTitle` to use
a taller line-height for readability
([#7185](elastic/eui#7185))
- Fixed `EuiComboBox` to correctly truncate selected items when
displayed as pills and plain text
([#7193](elastic/eui#7193))

**Accessibility**

- Added `aria-current` attribute to `EuiTablePagination`
([#7186](elastic/eui#7186))

**CSS-in-JS conversions**

- Converted `EuiDroppable` and `EuiDraggable` to Emotion; Removed
`$euiDragAndDropSpacing` Sass variables
([#7187](elastic/eui#7187))

---------

Co-authored-by: Patryk Kopycinski <[email protected]>
Co-authored-by: Jan Monschke <[email protected]>
Co-authored-by: Thomas Watson <[email protected]>
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.

[EuiCallOut] Add optional close button
7 participants