Skip to content

Commit

Permalink
fix(OverflowMenu): allow users to set focusTrap to false (#10829)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
tw15egan and kodiakhq[bot] authored Mar 1, 2022
1 parent 9e3f497 commit 03cae68
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4532,6 +4532,7 @@ Map {
"ariaLabel": "open and close list of options",
"direction": "bottom",
"flipped": false,
"focusTrap": true,
"iconDescription": "open and close list of options",
"light": false,
"menuOffset": [Function],
Expand Down Expand Up @@ -4569,6 +4570,9 @@ Map {
"flipped": Object {
"type": "bool",
},
"focusTrap": Object {
"type": "bool",
},
"iconClass": Object {
"type": "string",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2394,6 +2394,7 @@ exports[`DataTable should render 1`] = `
className="bx--toolbar-action bx--overflow-menu"
direction="bottom"
flipped={true}
focusTrap={true}
iconDescription="Settings"
light={false}
menuOffset={[Function]}
Expand Down Expand Up @@ -3381,6 +3382,7 @@ exports[`DataTable sticky header should render 1`] = `
className="bx--toolbar-action bx--overflow-menu"
direction="bottom"
flipped={true}
focusTrap={true}
iconDescription="Settings"
light={false}
menuOffset={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ exports[`DataTable.TableToolbarMenu should render 1`] = `
className="custom-class bx--toolbar-action bx--overflow-menu"
direction="bottom"
flipped={true}
focusTrap={true}
iconDescription="Add"
light={false}
menuOffset={[Function]}
Expand Down
9 changes: 8 additions & 1 deletion packages/react/src/components/OverflowMenu/OverflowMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ class OverflowMenu extends Component {
*/
flipped: PropTypes.bool,

/**
* Enable or disable focus trap behavior
*/
focusTrap: PropTypes.bool,

/**
* The CSS class for the icon.
*/
Expand Down Expand Up @@ -234,6 +239,7 @@ class OverflowMenu extends Component {
open: false,
direction: DIRECTION_BOTTOM,
flipped: false,
focusTrap: true,
renderIcon: OverflowMenuVertical16,
onClick: () => {},
onKeyDown: () => {},
Expand Down Expand Up @@ -461,6 +467,7 @@ class OverflowMenu extends Component {
iconDescription,
direction,
flipped,
focusTrap,
menuOffset,
menuOffsetFlip,
iconClass,
Expand Down Expand Up @@ -528,7 +535,7 @@ class OverflowMenu extends Component {

const wrappedMenuBody = (
<FloatingMenu
focusTrap
focusTrap={focusTrap}
triggerRef={this._triggerRef}
menuDirection={direction}
menuOffset={flipped ? menuOffsetFlip : menuOffset}
Expand Down

0 comments on commit 03cae68

Please sign in to comment.