Skip to content

Commit 8843f77

Browse files
authored
Merge pull request #555 from facultyai/dropdownmenuitem-toggle
Dropdownmenuitem toggle
2 parents cfbcb6b + 5c74bac commit 8843f77

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/components/dropdownmenu/DropdownMenu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ DropdownMenu.propTypes = {
153153

154154
/**
155155
* Set the color of the DropdownMenu toggle. Available options are: 'primary',
156-
* 'secondary', 'success', 'warning', 'danger', 'info', 'link' or any valid CSS
156+
* 'secondary', 'success', 'warning', 'danger', 'info', 'link' or any valid CSS
157157
* color of your choice (e.g. a hex code, a decimal code or a CSS color name)
158158
* Default: 'secondary'
159159
*/

src/components/dropdownmenu/DropdownMenuItem.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const DropdownMenuItem = props => {
4848
href={disabled ? null : href}
4949
disabled={disabled}
5050
target={useLink && target}
51+
toggle={toggle}
5152
{...omit(['setProps'], otherProps)}
5253
data-dash-is-loading={
5354
(loading_state && loading_state.is_loading) || undefined

src/components/dropdownmenu/__tests__/DropdownMenuItem.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,22 @@ describe('DropdownMenuItem', () => {
120120
dropdownMenu.container.querySelector('.dropdown-menu')
121121
).not.toHaveClass('show');
122122
});
123+
124+
test("doesn't dismiss parent DropdownMenu when clicked if toggle=false", () => {
125+
const dropdownMenu = render(
126+
<DropdownMenu label="toggle">
127+
<DropdownMenuItem toggle={false}>Clickable</DropdownMenuItem>
128+
</DropdownMenu>
129+
);
130+
131+
userEvent.click(dropdownMenu.getByText('toggle'));
132+
133+
expect(dropdownMenu.container.querySelector('.dropdown-menu')).toHaveClass(
134+
'show'
135+
);
136+
userEvent.click(dropdownMenu.getByText('Clickable'));
137+
expect(
138+
dropdownMenu.container.querySelector('.dropdown-menu')
139+
).toHaveClass('show');
140+
});
123141
});

0 commit comments

Comments
 (0)