[EuiBasicTable][EuiInMemoryTable] Add new truncationText line API#7254
[EuiBasicTable][EuiInMemoryTable] Add new truncationText line API#7254cee-chen merged 6 commits intoelastic:mainfrom
truncationText line API#7254Conversation
6c37c1d to
c5cd36a
Compare
- remove unnecessary fragments, import organization
+ fix default starting valign - should be middle, not top
c5cd36a to
122628d
Compare
| * Indicates whether this column should truncate overflowing text content. | ||
| * - Set to `true` to enable single-line truncation. | ||
| * - To enable multi-line truncation, use a configuration object with `lines` | ||
| * set to a number of lines to truncate to. | ||
| */ | ||
| truncateText?: boolean; | ||
| truncateText?: boolean | { lines: number }; |
There was a problem hiding this comment.
@elastic/eui-team [Request for votes/feedback]
As always, naming things & consistency are the hardest part of our jobs. Here's EuiDataGrid's current line truncation API:
<EuiDataGrid
rowHeightsOptions={{
defaultHeight: { lineCount: 2 },
}}
/>And here's what the above proposed API would look like:
<EuiBasicTable
columns={[
{
field: 'myField',
name: 'My field',
truncateText: { lines: 2 },
}
]}
/>My question for you all is whether we should change lines to lineCount to match EuiDataGrid, or let them be different (or, if someone else has a totally different naming suggestion, feel free to throw that in the ring as well).
I opted for lines when I was first writing this because it felt more natural sounding to me - I only remembered after I was done that EuiDataGrid had its own API.
FWIW, EuiDataGrid generally has a very different data structure and API architecture to our table components, so I don't think it would be a huge loss for this to be different either, but maybe I'm downplaying that. I'd love to hear people's takes!
There was a problem hiding this comment.
@1Copenut FYI, hoping to get this merged in for next week's release - any chance you can review this PR some time Monday morning? Thanks!
There was a problem hiding this comment.
I think I'm onboard with your keeping these as separate names lineCount and lines respectively. The APIs are distinct enough that I'd look them / wouldn't assume the key was the same.
There was a problem hiding this comment.
Awesome. Thanks Trevor!
|
Preview staging links for this PR:
|
💚 Build Succeeded
History
|
1Copenut
left a comment
There was a problem hiding this comment.
👍 LGTM. I left a comment agreeing with your reasoning for having different API key values. LMK if there's any retesting or additional review needed Monday and I'll grab it first thing.
| * Indicates whether this column should truncate overflowing text content. | ||
| * - Set to `true` to enable single-line truncation. | ||
| * - To enable multi-line truncation, use a configuration object with `lines` | ||
| * set to a number of lines to truncate to. | ||
| */ | ||
| truncateText?: boolean; | ||
| truncateText?: boolean | { lines: number }; |
There was a problem hiding this comment.
I think I'm onboard with your keeping these as separate names lineCount and lines respectively. The APIs are distinct enough that I'd look them / wouldn't assume the key was the same.
`v88.5.4`⏩`v89.0.0` --- ## [`89.0.0`](https://github.com/elastic/eui/tree/v89.0.0) - Added new `pushAnimation` prop to push `EuiFlyout`s, which enables a slide in animation ([#7239](elastic/eui#7239)) - Updated `EuiComboBox` to use `EuiInputPopover` under the hood ([#7246](elastic/eui#7246)) - Added `inputPopoverProps` to `EuiComboBox`, which allows customizing the underlying popover ([#7246](elastic/eui#7246)) - Added a new beta `EuiTextBlockTruncate` component for multi-line truncation ([#7250](elastic/eui#7250)) - Updated `EuiBasicTable` and `EuiInMemoryTable` to support multi-line truncation. This can be set via `truncateText.lines` in the `columns` prop. ([#7254](elastic/eui#7254)) **Bug fixes** - Fixed `EuiFlexGroup` and `EuiFlexGrid`'s `m` gutter size ([#7251](elastic/eui#7251)) - Fixed focus trap rerender issues in `EuiFlyout` with memoization ([#7259](elastic/eui#7259)) - Fixed a visual bug with `EuiContextMenu`'s animation between panels ([#7268](elastic/eui#7268)) **Breaking changes** - EUI's global body font-size now respects the `font.defaultUnits` token. This means that the global font size will use the `rem` unit by default, instead of `px`. ([#7182](elastic/eui#7182)) - Removed exported `accessibleClickKeys`, `comboBoxKeys`, and `cascadingMenuKeys` services. Use the generic `keys` service instead ([#7256](elastic/eui#7256)) - Removed `EuiColorStops` due to low usage ([#7262](elastic/eui#7262)) - Removed `EuiSuggest`. We recommend using `EuiSelectable` or `EuiComboBox` instead ([#7263](elastic/eui#7263)) - Removed `euiHeaderAffordForFixed` Sass mixin, and `$euiHeaderHeight` and `$euiHeaderHeightCompensation` Sass variables. Use the CSS variable `--var(euiFixedHeadersOffset, 0)` instead. ([#7264](elastic/eui#7264)) **Accessibility** - When using `rem` or `em` font units, EUI now respects, instead of ignoring, browser default font sizes set by end users. ([#7182](elastic/eui#7182))
`v88.5.4`⏩`v89.0.0` --- ## [`89.0.0`](https://github.com/elastic/eui/tree/v89.0.0) - Added new `pushAnimation` prop to push `EuiFlyout`s, which enables a slide in animation ([elastic#7239](elastic/eui#7239)) - Updated `EuiComboBox` to use `EuiInputPopover` under the hood ([elastic#7246](elastic/eui#7246)) - Added `inputPopoverProps` to `EuiComboBox`, which allows customizing the underlying popover ([elastic#7246](elastic/eui#7246)) - Added a new beta `EuiTextBlockTruncate` component for multi-line truncation ([elastic#7250](elastic/eui#7250)) - Updated `EuiBasicTable` and `EuiInMemoryTable` to support multi-line truncation. This can be set via `truncateText.lines` in the `columns` prop. ([elastic#7254](elastic/eui#7254)) **Bug fixes** - Fixed `EuiFlexGroup` and `EuiFlexGrid`'s `m` gutter size ([elastic#7251](elastic/eui#7251)) - Fixed focus trap rerender issues in `EuiFlyout` with memoization ([elastic#7259](elastic/eui#7259)) - Fixed a visual bug with `EuiContextMenu`'s animation between panels ([elastic#7268](elastic/eui#7268)) **Breaking changes** - EUI's global body font-size now respects the `font.defaultUnits` token. This means that the global font size will use the `rem` unit by default, instead of `px`. ([elastic#7182](elastic/eui#7182)) - Removed exported `accessibleClickKeys`, `comboBoxKeys`, and `cascadingMenuKeys` services. Use the generic `keys` service instead ([elastic#7256](elastic/eui#7256)) - Removed `EuiColorStops` due to low usage ([elastic#7262](elastic/eui#7262)) - Removed `EuiSuggest`. We recommend using `EuiSelectable` or `EuiComboBox` instead ([elastic#7263](elastic/eui#7263)) - Removed `euiHeaderAffordForFixed` Sass mixin, and `$euiHeaderHeight` and `$euiHeaderHeightCompensation` Sass variables. Use the CSS variable `--var(euiFixedHeadersOffset, 0)` instead. ([elastic#7264](elastic/eui#7264)) **Accessibility** - When using `rem` or `em` font units, EUI now respects, instead of ignoring, browser default font sizes set by end users. ([elastic#7182](elastic/eui#7182))
Summary
closes #7226
Proposed API:
Single (
true) vs multi-line truncation:QA
Addresscolumn truncates after 2 lines (and does not truncate if the address is short enough) on all layoutsGeneral checklist
- [ ] Checked in both light and dark modes- [ ] Checked for accessibility including keyboard-only and screenreader modes@defaultif default values are missing)and playground toggles- [ ] Checked Code Sandbox works for any docs examplesand cypress tests- [ ] If applicable, added the breaking change issue label (and filled out the breaking change checklist)- [ ] Updated the Figma library counterpart