Skip to content

Commit ffe6535

Browse files
committed
Make non-truncate opt-in
1 parent da50a14 commit ffe6535

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

packages/react/src/TreeView/TreeView.docs.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@
6969
"name": "onSelect",
7070
"type": "(event: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void"
7171
},
72+
{
73+
"name": "truncate",
74+
"type": "boolean",
75+
"defaultValue": "true",
76+
"description": "Truncate the item's text content with an ellipsis."
77+
},
7278
{
7379
"name": "ref",
7480
"type": "React.Ref<HTMLElement>"

packages/react/src/TreeView/TreeView.features.stories.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,15 +1046,13 @@ export const LeadingAction: StoryFn = () => {
10461046

10471047
export const MultilineItems: StoryFn = () => (
10481048
<nav aria-label="Files changed">
1049-
<TreeView aria-label="Files changed">
1049+
<TreeView aria-label="Files changed" truncate={false}>
10501050
<TreeView.Item id="src" defaultExpanded>
10511051
<TreeView.LeadingVisual>
10521052
<TreeView.DirectoryIcon />
10531053
</TreeView.LeadingVisual>
1054-
<div style={{whiteSpace: 'wrap'}}>
1055-
this is a very long directory name that we have intentionally allowed to wrap over multiple lines to
1056-
demonstrate alignment
1057-
</div>
1054+
this is a very long directory name that we have intentionally allowed to wrap over multiple lines to demonstrate
1055+
alignment
10581056
<TreeView.SubTree>
10591057
<TreeView.Item id="src/Avatar.tsx">
10601058
<TreeView.LeadingVisual>
@@ -1071,9 +1069,7 @@ export const MultilineItems: StoryFn = () => (
10711069
<TreeView.LeadingVisual>
10721070
<TreeView.DirectoryIcon />
10731071
</TreeView.LeadingVisual>
1074-
<div style={{whiteSpace: 'wrap'}}>
1075-
this is a medium directory name that we wrap over 2 lines to demonstrate alignment
1076-
</div>
1072+
this is a medium directory name that we wrap over 2 lines to demonstrate alignment
10771073
<TreeView.TrailingVisual label="Added">
10781074
<Octicon icon={DiffAddedIcon} color="success.fg" />
10791075
</TreeView.TrailingVisual>

packages/react/src/TreeView/TreeView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ const Root: React.FC<TreeViewProps> = ({
285285
'aria-labelledby': ariaLabelledby,
286286
children,
287287
flat,
288-
truncate,
288+
truncate = true,
289289
className,
290290
}) => {
291291
const containerRef = React.useRef<HTMLUListElement>(null)

0 commit comments

Comments
 (0)