Skip to content

Commit 81ec00f

Browse files
authored
fix: endReached prop in _Options of PaginatedSelectFiltered Component (#475)
* endReached in Options * more fixes * update loki files
1 parent dbdbf58 commit 81ec00f

10 files changed

+38
-4
lines changed
Loading
Loading

packages/fuselage/src/components/OptionsPaginated/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export const CheckOption = React.memo(
2828
export const OptionsPaginated = React.forwardRef(
2929
(
3030
{
31+
title,
3132
multiple,
3233
renderEmpty: EmptyComponent = Empty,
3334
options,
@@ -43,6 +44,7 @@ export const OptionsPaginated = React.forwardRef(
4344
const { value, label, selected } = data;
4445
return (
4546
<OptionComponent
47+
{...(title && { title: label })}
4648
role='option'
4749
label={label}
4850
onMouseDown={(e) => {

packages/fuselage/src/components/SelectPaginated/PaginatedMultiSelect.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import Margins from '../Margins';
1212
import { OptionsPaginated, useVisible } from '../OptionsPaginated';
1313
import { Focus, Addon } from '../Select';
1414

15-
const SelectedOptions = React.memo((props) => <Chip {...props} />);
15+
const SelectedOptions = React.memo((props) => (
16+
<Chip maxWidth='150px' withTruncatedText {...props} />
17+
));
1618

1719
const prevent = (e) => {
1820
e.preventDefault();
@@ -21,6 +23,7 @@ const prevent = (e) => {
2123
};
2224

2325
export const PaginatedMultiSelect = ({
26+
withTitle,
2427
value,
2528
filter,
2629
options = [],
@@ -94,6 +97,11 @@ export const PaginatedMultiSelect = ({
9497
/>
9598
{currentValue.map((value) => (
9699
<SelectedOptions
100+
{...(withTitle && {
101+
title:
102+
value.label ||
103+
options.find((val) => val.value === value)?.label,
104+
})}
97105
tabIndex={-1}
98106
role='option'
99107
key={value && value.value}
@@ -133,6 +141,7 @@ export const PaginatedMultiSelect = ({
133141
<AnimatedVisibility visibility={visible}>
134142
<Position anchor={containerRef}>
135143
<_Options
144+
{...(withTitle && { title: withTitle })}
136145
width={borderBoxSize.inlineSize}
137146
onMouseDown={prevent}
138147
multiple

packages/fuselage/src/components/SelectPaginated/PaginatedSelect.js

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const useDidUpdate = (func = []) => {
5050

5151
export const PaginatedSelect = ({
5252
value,
53+
withTitle,
5354
filter,
5455
setFilter,
5556
error,
@@ -59,6 +60,7 @@ export const PaginatedSelect = ({
5960
onChange = () => {},
6061
placeholder = '',
6162
renderOptions: _Options = OptionsPaginated,
63+
endReached,
6264
...props
6365
}) => {
6466
const [internalValue, setInternalValue] = useState(value);
@@ -144,11 +146,13 @@ export const PaginatedSelect = ({
144146
</Wrapper>
145147
<PositionAnimated visible={visible} anchor={containerRef}>
146148
<_Options
149+
{...(withTitle && { title: withTitle })}
147150
width={borderBoxSize.inlineSize}
148151
role='listbox'
149152
filter={filter}
150153
options={options}
151154
onSelect={internalChangedByClick}
155+
endReached={endReached}
152156
/>
153157
</PositionAnimated>
154158
</Box>

packages/fuselage/src/components/SelectPaginated/SelectPaginated.stories.mdx

+22-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ export const thumb =
1414
'data:image/gif;base64,R0lGODlhAQABAIAAAMLCwgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==';
1515

1616
export const optionsEllipses = [
17-
[11, 'Very very very very very very very very very large text'],
17+
{
18+
value: 1000,
19+
label: 'Very very very very very very very very very large text',
20+
},
1821
...options,
1922
];
2023

@@ -37,6 +40,17 @@ An input for selection of options.
3740
</Story>
3841
</Canvas>
3942

43+
<Canvas>
44+
<Story name='WithTitle'>
45+
<PaginatedSelect
46+
withTitle
47+
width='250px'
48+
placeholder='Placeholder here...'
49+
options={optionsEllipses}
50+
/>
51+
</Story>
52+
</Canvas>
53+
4054
<Canvas>
4155
<Story name='Error'>
4256
<PaginatedSelect
@@ -87,7 +101,7 @@ An input for selection of options.
87101
<Story name='Select with filter and ellipses'>
88102
<PaginatedSelectFiltered
89103
width='250px'
90-
value={11}
104+
value={1000}
91105
placeholder='Placeholder here...'
92106
options={optionsEllipses}
93107
/>
@@ -125,7 +139,12 @@ An input for selection of options.
125139

126140
<Canvas>
127141
<Story name='PaginatedMultiSelect'>
128-
<PaginatedMultiSelect placeholder='Placeholder here...' options={options} />
142+
<PaginatedMultiSelect
143+
withTitle
144+
placeholder='Placeholder here...'
145+
value={[1000, 2, 3]}
146+
options={optionsEllipses}
147+
/>
129148
</Story>
130149
</Canvas>
131150

0 commit comments

Comments
 (0)