Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

Commit

Permalink
fix(OverflowMenu): check menu body and click handler event origin (#1903
Browse files Browse the repository at this point in the history
)

* fix(OverflowMenu): check menu body and click handler event origin

* docs(Toolbar): add input props to radio button
  • Loading branch information
emyarod authored and asudoh committed Feb 21, 2019
1 parent 64f81a5 commit 36b2849
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
6 changes: 4 additions & 2 deletions src/components/OverflowMenu/OverflowMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,10 @@ export default class OverflowMenu extends Component {
};

handleClick = evt => {
this.setState({ open: !this.state.open });
this.props.onClick(evt);
if (!this._menuBody || !this._menuBody.contains(evt.target)) {
this.setState({ open: !this.state.open });
this.props.onClick(evt);
}
};

handleKeyDown = evt => {
Expand Down
23 changes: 6 additions & 17 deletions src/components/Toolbar/Toolbar-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';

import { iconFilter } from 'carbon-icons';
import Toolbar, {
ToolbarItem,
Expand All @@ -25,7 +24,7 @@ const toolbarProps = {
className: 'some-class',
};

const checkboxEvents = {
const inputProps = {
className: 'some-class',
onChange: action('onChange'),
};
Expand All @@ -39,25 +38,13 @@ storiesOf('Toolbar', module).add(
<OverflowMenu icon={iconFilter} floatingMenu>
<ToolbarTitle title="FILTER BY" />
<ToolbarOption>
<Checkbox
{...checkboxEvents}
id="opt-1"
labelText="Filter option 1"
/>
<Checkbox {...inputProps} id="opt-1" labelText="Filter option 1" />
</ToolbarOption>
<ToolbarOption>
<Checkbox
{...checkboxEvents}
id="opt-2"
labelText="Filter option 2"
/>
<Checkbox {...inputProps} id="opt-2" labelText="Filter option 2" />
</ToolbarOption>
<ToolbarOption>
<Checkbox
{...checkboxEvents}
id="opt-3"
labelText="Filter option 3"
/>
<Checkbox {...inputProps} id="opt-3" labelText="Filter option 3" />
</ToolbarOption>
</OverflowMenu>
</ToolbarItem>
Expand All @@ -68,6 +55,7 @@ storiesOf('Toolbar', module).add(
<ToolbarTitle title="ROW HEIGHT" />
<ToolbarOption>
<RadioButton
{...inputProps}
value="short"
id="radio-1"
name="toolbar-radio"
Expand All @@ -76,6 +64,7 @@ storiesOf('Toolbar', module).add(
</ToolbarOption>
<ToolbarOption>
<RadioButton
{...inputProps}
value="tall"
id="radio-2"
name="toolbar-radio"
Expand Down

0 comments on commit 36b2849

Please sign in to comment.