Skip to content

Commit 882d847

Browse files
committed
Remove reference to paginationOption in getOptionLabel
1 parent af88cc0 commit 882d847

File tree

4 files changed

+6
-15
lines changed

4 files changed

+6
-15
lines changed

src/components/Typeahead/Typeahead.test.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,7 @@ describe('<Typeahead>', () => {
325325

326326
it('calls `onPaginate` when `labelKey` is a function', async () => {
327327
const user = userEvent.setup();
328-
render(
329-
<Pagination
330-
labelKey={(o) => (o as Option).name}
331-
onPaginate={onPaginate}
332-
/>
333-
);
328+
render(<Pagination labelKey={() => 'label'} onPaginate={onPaginate} />);
334329

335330
getInput().focus();
336331
await user.keyboard('{ArrowUp}{Enter}');

src/components/TypeaheadMenu/TypeaheadMenu.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ CustomOption.args = {
4141
export const Pagination = Template.bind({});
4242
Pagination.args = {
4343
...defaultProps,
44-
options: [...options.slice(0, 5), { paginationOption: true }],
44+
options: [...options.slice(0, 5), { name: '', paginationOption: true }],
4545
};
4646

4747
export const CustomChildren = Template.bind({});

src/utils/getOptionLabel.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('getOptionLabel', () => {
3131
};
3232

3333
const paginationOption = {
34-
[getStringLabelKey(labelKeyFn)]: 'bar',
34+
name: 'bar',
3535
paginationOption: true,
3636
};
3737

@@ -47,12 +47,12 @@ describe('getOptionLabel', () => {
4747

4848
it('throws an error when an invalid option is encountered', () => {
4949
const willThrow = () => getOptionLabel([], 'name');
50-
expect(willThrow).toThrowError(Error);
50+
expect(willThrow).toThrow(Error);
5151
});
5252

5353
it('throws an error when `option` is an object and no labelkey is specified', () => {
5454
// @ts-expect-error
5555
const willThrow = () => getOptionLabel(option);
56-
expect(willThrow).toThrowError(Error);
56+
expect(willThrow).toThrow(Error);
5757
});
5858
});

src/utils/getOptionLabel.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ import type { LabelKey, Option } from '../types';
1313
*/
1414
function getOptionLabel(option: Option, labelKey: LabelKey): string {
1515
// Handle internally created options first.
16-
if (
17-
!isString(option) &&
18-
(hasOwnProperty(option, 'paginationOption') ||
19-
hasOwnProperty(option, 'customOption'))
20-
) {
16+
if (!isString(option) && hasOwnProperty(option, 'customOption')) {
2117
return option[getStringLabelKey(labelKey)] as string;
2218
}
2319

0 commit comments

Comments
 (0)