Skip to content

Commit 1188241

Browse files
author
Karthik B
authored
Sw-4530 Use fixed height with scroll on TextTruncated popper (#444)
- for large lists, the popper can get very large and out of the fold - separate story for large list of values
1 parent 58655e1 commit 1188241

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/components/TextTruncated/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ const useStyles = makeStyles((theme: Theme) => ({
99
border: `1px solid ${theme.palette.TwClrBrdrTertiary}`,
1010
},
1111
},
12+
popper: {
13+
maxHeight: '200px',
14+
overflow: 'auto',
15+
},
1216
tooltip: {
1317
backgroundColor: `${theme.palette.TwClrBg} !important`,
1418
color: `${theme.palette.TwClrTxt} !important`,
@@ -136,6 +140,7 @@ export default function TextTruncated(props: Props): JSX.Element {
136140
arrow={true}
137141
classes={{
138142
arrow: classes.arrow,
143+
popper: classes.popper,
139144
tooltip: classes.tooltip,
140145
}}
141146
open={showAllOpen}

src/stories/TextTruncated.stories.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,19 @@ const Template: Story<TextTruncatedProps> = (args) => {
1313
return <TextTruncated {...args} />;
1414
};
1515

16+
const stringList = ['elephant', 'foo', 'bar', 'baz', 'spam', 'bacon', 'eggs'];
17+
18+
let largeList = stringList;
19+
20+
for (let i = 0; i < 5; i++) {
21+
largeList = [...largeList, ...largeList];
22+
}
23+
24+
1625
export const Default = Template.bind({});
1726

1827
Default.args = {
19-
stringList: ['elephant', 'foo', 'bar', 'baz', 'spam', 'bacon', 'eggs'],
28+
stringList,
2029
maxLengthPx: 200,
2130
showAllStyle: {fontSize: 14},
2231
textStyle: {fontSize: 14},
@@ -25,6 +34,13 @@ Default.args = {
2534
placeHolder: undefined,
2635
};
2736

37+
export const LargeList = Template.bind({});
38+
39+
LargeList.args = {
40+
...Default.args,
41+
stringList: largeList,
42+
};
43+
2844
export const WithPlaceholder = Template.bind({});
2945

3046
WithPlaceholder.args = {

0 commit comments

Comments
 (0)