Repository navigation
refactor: move internal parts and utils from select to listbox #5204
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
Changes from all commits
3ffd401
e700d81
10b678b
8875ae1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { act, renderHook } from '../../__tests__/render-hook'; | ||
| import type { DropdownOption } from '../../internal/components/option/interfaces'; | ||
| import { useNativeSearch } from '../utils/use-native-search'; | ||
| import { act, renderHook } from '../../../../__tests__/render-hook'; | ||
| import type { DropdownOption } from '../../option/interfaces'; | ||
| import { useTypeAhead } from '../use-type-ahead'; | ||
|
|
||
| const options: DropdownOption[] = [ | ||
| { option: { label: 'option 1', value: 'option1' } }, | ||
|
|
@@ -19,8 +19,8 @@ const initialProps = { | |
| highlightedOption: null, | ||
| }; | ||
|
|
||
| describe('useNativeSearch', () => { | ||
| const hook = renderHook(useNativeSearch, { | ||
| describe('useTypeAhead', () => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is "type ahead"?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the same feature that used to be called |
||
| const hook = renderHook(useTypeAhead, { | ||
| initialProps: initialProps, | ||
| }); | ||
|
|
||
|
|
@@ -47,7 +47,7 @@ describe('useNativeSearch', () => { | |
| }); | ||
|
|
||
| test('should not highlight an option when isEnabled is false', () => { | ||
| const hook = renderHook(useNativeSearch, { | ||
| const hook = renderHook(useTypeAhead, { | ||
| initialProps: { | ||
| ...initialProps, | ||
| isEnabled: false, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,16 +8,14 @@ interface ItemProps { | |
| index: number; | ||
| getOptionProps: any; | ||
| filteringValue: string; | ||
| checkboxes: boolean; | ||
| } | ||
|
|
||
| export const getItemProps = ({ option, index, getOptionProps, filteringValue, checkboxes = false }: ItemProps) => { | ||
| export const getItemProps = ({ option, index, getOptionProps, filteringValue }: ItemProps) => { | ||
| const optionProps = getOptionProps(option, index); | ||
| optionProps.filteringValue = filteringValue; | ||
| const { inGroupIndex, groupIndex, throughIndex } = getTestOptionIndexes(option) || {}; | ||
| return { | ||
| ...optionProps, | ||
| hasCheckbox: checkboxes, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ['data-group-index']: groupIndex, | ||
| ['data-child-index']: inGroupIndex, | ||
| ['data-test-index']: throughIndex, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove this test?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test became a duplicate. Its only difference from the first test was the checkboxes option. After merging the Select and Multiselect rows into one, whether a row shows a checkbox depends on whether it's a Select or Multiselect row, so getItemProps no longer takes that option. Without it, the two tests were identical, so I kept one. Here is the first test test