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

[EuiComboBox] Update to dogfood EuiTextTruncate #7028

Merged
merged 49 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
23aba4c
:lipstick: Move end truncation in separate class
dej611 Aug 2, 2023
00720dc
:heavy_plus_sign: Add canvas mock library for jest
dej611 Aug 2, 2023
8b67204
:sparkles: Add truncation middle feature
dej611 Aug 2, 2023
00241ea
:memo: Update documentation
dej611 Aug 2, 2023
df85489
Merge remote-tracking branch 'origin/master' into fix/5997
dej611 Aug 2, 2023
83bd86a
:ok_hand: Remove canvas usage + remove dependency
dej611 Aug 3, 2023
ea1be6c
:fire: Remove ellipsis
dej611 Aug 3, 2023
cb37976
:recycle: Reduce append operations
dej611 Aug 3, 2023
e269b00
Merge branch 'main' into fix/5997
cee-chen Aug 20, 2023
1aeec8c
Revert yarn.lock changes
cee-chen Aug 20, 2023
e07791d
revert jest config file changes
cee-chen Aug 21, 2023
6131706
Set up `EuiTextTruncate` component
cee-chen Aug 21, 2023
ce0bf7e
export / rest spread
cee-chen Aug 21, 2023
0261f23
Merge branch 'main' into fix/5997
cee-chen Aug 21, 2023
79cb351
More component cleanup/changes
cee-chen Aug 21, 2023
3f9671f
Add `onResize` callback + resize observer story
cee-chen Aug 21, 2023
d5d6f3d
Add startEnd anchor position logic needed for combobox search
cee-chen Aug 21, 2023
006eefa
[DX] Make the render prop optional
cee-chen Aug 21, 2023
0c0703c
[typing] Make `truncation` prop optional
cee-chen Aug 22, 2023
572ce0c
Rename `startEndAnchor` to `truncationPosition` + other cleanup
cee-chen Aug 22, 2023
09cc1c3
Write tests
cee-chen Aug 22, 2023
b45b719
Add docs page and examples for new component
cee-chen Aug 22, 2023
17047d1
Fix/workaround two crashing `truncationOffset` loops
cee-chen Aug 22, 2023
1af3b49
Improve screen reader and copy UX
cee-chen Aug 22, 2023
f46b348
Revert EuiComboBox changes to main
cee-chen Aug 22, 2023
8491224
Add new `truncationProps` and `renderTruncatedOption` logic
cee-chen Aug 22, 2023
c69441a
Add docs section for combobox truncation
cee-chen Aug 22, 2023
10dc0e2
Attempt to fix Cypress CI failures caused by fonts
cee-chen Aug 23, 2023
f219119
[REFACTOR] Move truncation string logic to a separate vanilla JS class
cee-chen Aug 23, 2023
64aaebd
Clean up `truncationOffset` edge case behavior
cee-chen Aug 23, 2023
7d5ce5a
Fix storybook controls
cee-chen Aug 23, 2023
5fd309e
it's hard to word good
cee-chen Aug 23, 2023
a5837bb
[PR feedback] Expand utilities for to specify DOM vs. canvas render m…
cee-chen Aug 23, 2023
767a44e
[misc cleanup] fix `truncateStart` typing
cee-chen Aug 23, 2023
4cd6ad5
Naming things is hard
cee-chen Aug 23, 2023
85ccc1c
Fix CI font issues again :|
cee-chen Aug 24, 2023
a1c487d
[PR feedback] Improve perf of DOM measurement
cee-chen Aug 24, 2023
b6b67b0
Update `EuiTextTruncate` to support using `TruncationUtilsForCanvas`
cee-chen Aug 24, 2023
f4a9af4
Add documentation section and warnings around performance
cee-chen Aug 24, 2023
4a96de8
[misc cleanup] improve tests
cee-chen Aug 24, 2023
879b38e
Add CSS comments/dev documentation
cee-chen Aug 25, 2023
30196af
Minor test cleanup
cee-chen Aug 25, 2023
6718b37
Merge branch 'main' into fix/5997
cee-chen Sep 1, 2023
5098c4c
changelog
cee-chen Sep 1, 2023
3cb8c0d
Make docs example less confusing
cee-chen Sep 1, 2023
e28a66e
Merge branch 'main' into fix/5997
cee-chen Sep 18, 2023
998ecb1
Add tests
cee-chen Sep 18, 2023
d188bb5
[Cypress] Fix font calculation
cee-chen Sep 18, 2023
b971297
Add `shouldRenderCustomStyles` Jest tests
cee-chen Sep 18, 2023
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
41 changes: 41 additions & 0 deletions src-docs/src/views/combo_box/combo_box_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
EuiCode,
EuiComboBox,
EuiText,
EuiTextTruncate,
EuiCallOut,
} from '../../../../src/components';

Expand Down Expand Up @@ -82,6 +83,21 @@ const renderOptionSnippet = `<EuiComboBox
renderOption={renderOption}
/>`;

import Truncation from './truncation';
const truncationSource = require('!!raw-loader!./truncation');
const truncationSnippet = `<EuiComboBox
aria-label="Accessible screen reader label"
placeholder="Select or create options"
options={options}
selectedOptions={selectedOptions}
onChange={onChange}
onCreateOption={onCreateOption}
truncationProps={{
truncation: 'start',
truncationOffset: 5,
}}
/>`;

import Groups from './groups';
const groupsSource = require('!!raw-loader!./groups');
const groupsSnippet = `<EuiComboBox
Expand Down Expand Up @@ -445,6 +461,31 @@ export const ComboBoxExample = {
},
],
},
{
title: 'Truncation',
source: [
{
type: GuideSectionTypes.TSX,
code: truncationSource,
},
],
text: (
<p>
By default, <strong>EuiComboBox</strong> truncates long option text at
the end of the string. You can use <EuiCode>truncationProps</EuiCode>{' '}
and almost any prop that{' '}
<Link to="/utilities/text-truncate">
<strong>EuiTextTruncate</strong>
</Link>{' '}
accepts to configure this behavior. This can be configured at the{' '}
<strong>EuiComboBox</strong> level, as well as by each individual
option.
</p>
),
props: { EuiComboBox, EuiComboBoxOptionOption, EuiTextTruncate },
snippet: truncationSnippet,
demo: <Truncation />,
},
{
title: 'Groups',
source: [
Expand Down
109 changes: 109 additions & 0 deletions src-docs/src/views/combo_box/truncation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import React, { useState } from 'react';

import {
useGeneratedHtmlId,
EuiFlexGroup,
EuiFlexItem,
EuiButtonGroup,
EuiFieldNumber,
EuiTextTruncationTypes,
EuiTitle,
EuiSpacer,
EuiComboBox,
EuiComboBoxOptionOption,
} from '../../../../src';

const options: EuiComboBoxOptionOption[] = [
{
label:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, lorem ispum',
},
{
label:
'Phasellus enim turpis, molestie ut nisi ut, suscipit tristique libero',
},
{
label: 'Ut sagittis interdum nisi, pellentesque laoreet arcu blandit a',
},
{
label: 'Fusce sed viverra nisl',
},
{
label: 'Donec maximus est justo, eget semper lorem lacinia nec',
},
{
label: 'Vestibulum lobortis ipsum sit amet tellus scelerisque vestibulum',
},
{
label: 'This combobox option has an individual `truncationProps` override',
// Option `truncationProps` will override EuiComboBox `truncationProps`
truncationProps: {
truncation: 'start',
truncationOffset: 5,
},
},
];

export default () => {
const [selectedOptions, setSelected] = useState<EuiComboBoxOptionOption[]>(
[]
);
const onChange = (selectedOptions: EuiComboBoxOptionOption[]) => {
setSelected(selectedOptions);
};

const [truncation, setTruncation] = useState<EuiTextTruncationTypes>('end');
const [truncationOffset, setTruncationOffset] = useState(0);
const offsetId = useGeneratedHtmlId();

return (
<>
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiTitle size="xxs">
<h3>Truncation type</h3>
</EuiTitle>
<EuiSpacer size="xs" />
<EuiButtonGroup
legend="Truncation type"
idSelected={truncation}
onChange={(id) => setTruncation(id as EuiTextTruncationTypes)}
options={[
{ id: 'start', label: 'start ' },
{ id: 'end', label: 'end' },
{ id: 'startEnd', label: 'startEnd' },
{ id: 'middle', label: 'middle' },
]}
color="primary"
/>
</EuiFlexItem>
{(truncation === 'start' || truncation === 'end') && (
<EuiFlexItem grow={false}>
<EuiTitle size="xxs">
<h3 id={offsetId}>Truncation offset</h3>
</EuiTitle>
<EuiSpacer size="xs" />
<EuiFieldNumber
aria-labelledby={offsetId}
value={truncationOffset}
onChange={(e) => setTruncationOffset(Number(e.target.value))}
compressed
/>
</EuiFlexItem>
)}
</EuiFlexGroup>
<EuiSpacer />
<EuiComboBox
placeholder="Select options"
options={options}
selectedOptions={selectedOptions}
onChange={onChange}
isClearable={true}
truncationProps={{
truncation,
truncationOffset,
}}
/>
</>
);
};
Loading
Loading