diff --git a/ui/src/reusable_ui/components/dropdowns/Dropdown.tsx b/ui/src/reusable_ui/components/dropdowns/Dropdown.tsx index d18ac7b27..23d4f0daa 100644 --- a/ui/src/reusable_ui/components/dropdowns/Dropdown.tsx +++ b/ui/src/reusable_ui/components/dropdowns/Dropdown.tsx @@ -25,7 +25,7 @@ import {ErrorHandling} from 'src/shared/decorators/errors' interface Props { children: JSX.Element[] onChange: (value: any) => void - selectedKey: string + selectedID: string buttonColor?: ComponentColor buttonSize?: ComponentSize menuColor?: DropdownMenuColors @@ -109,7 +109,7 @@ class Dropdown extends Component { private get button(): JSX.Element { const { - selectedKey, + selectedID, disabled, buttonColor, buttonSize, @@ -118,9 +118,7 @@ class Dropdown extends Component { } = this.props const {expanded} = this.state - const selectedChild = children.find( - child => child.props.itemKey === selectedKey - ) + const selectedChild = children.find(child => child.props.id === selectedID) return ( { } private get menuItems(): JSX.Element { - const {selectedKey, maxMenuHeight, menuColor, children} = this.props + const {selectedID, maxMenuHeight, menuColor, children} = this.props const {expanded} = this.state if (expanded) { @@ -158,8 +156,8 @@ class Dropdown extends Component { return ( {child.props.children} @@ -168,10 +166,7 @@ class Dropdown extends Component { } return ( - + ) } else { throw new Error( diff --git a/ui/src/reusable_ui/components/dropdowns/DropdownDivider.tsx b/ui/src/reusable_ui/components/dropdowns/DropdownDivider.tsx index 6cf9a4115..d343730bb 100644 --- a/ui/src/reusable_ui/components/dropdowns/DropdownDivider.tsx +++ b/ui/src/reusable_ui/components/dropdowns/DropdownDivider.tsx @@ -9,7 +9,7 @@ import {ErrorHandling} from 'src/shared/decorators/errors' interface Props { children?: DropdownChild - itemKey: string + id: string text?: string } diff --git a/ui/src/reusable_ui/components/dropdowns/DropdownItem.tsx b/ui/src/reusable_ui/components/dropdowns/DropdownItem.tsx index 8a9e2a9c9..1859590a0 100644 --- a/ui/src/reusable_ui/components/dropdowns/DropdownItem.tsx +++ b/ui/src/reusable_ui/components/dropdowns/DropdownItem.tsx @@ -8,7 +8,7 @@ import {DropdownChild} from 'src/reusable_ui/types' import {ErrorHandling} from 'src/shared/decorators/errors' interface Props { - itemKey: string + id: string children: DropdownChild value: any selected?: boolean diff --git a/ui/src/reusable_ui/components/dropdowns/test/Dropdown.test.tsx b/ui/src/reusable_ui/components/dropdowns/test/Dropdown.test.tsx index 118476a16..100bc16ee 100644 --- a/ui/src/reusable_ui/components/dropdowns/test/Dropdown.test.tsx +++ b/ui/src/reusable_ui/components/dropdowns/test/Dropdown.test.tsx @@ -8,7 +8,7 @@ describe('Dropdown', () => { const wrapperSetup = (override = {}) => { const props = { - selectedKey: 'jimmy', + selectedID: 'jimmy', onChange: () => {}, children: null, ...override, @@ -19,7 +19,7 @@ describe('Dropdown', () => { const childSetup = (override = {}) => { const props = { - itemKey: 'jimmy', + id: 'jimmy', value: 'jimmy', children: 'jimmy', ...override, @@ -31,9 +31,9 @@ describe('Dropdown', () => { const childA = childSetup() const childB = childSetup({ - children: 'johnny', - itemKey: 'johnny', + id: 'johnny', value: 'johnny', + children: 'johnny', }) const children = [childA, childB] @@ -41,7 +41,7 @@ describe('Dropdown', () => { describe('collapsed', () => { beforeEach(() => { wrapper = wrapperSetup({ - selectedKey: 'johnny', + selectedID: 'johnny', children, }) }) @@ -54,7 +54,7 @@ describe('Dropdown', () => { describe('expanded', () => { beforeEach(() => { wrapper = wrapperSetup({ - selectedKey: 'johnny', + selectedID: 'johnny', children, }) @@ -65,14 +65,14 @@ describe('Dropdown', () => { expect(wrapper.find(Dropdown.Item)).toHaveLength(2) }) - it('can set the selectedKey', () => { + it('can set the selectedID', () => { const actualProps = wrapper .find(Dropdown.Item) .find({selected: true}) .props() const expectedProps = expect.objectContaining({ - itemKey: 'johnny', + id: 'johnny', value: 'johnny', })