Skip to content

Commit

Permalink
fix(ComposedModal): Address several problems with selectorsFloatingMe…
Browse files Browse the repository at this point in the history
…nus prop on ComposedModal (#10003)

* fix(ComposedModal): fix proptype and avoid prop passthrough to dom

* fix(ComposedModal): selectorsFloatingMenus adds rather than replaces

* chore: update api snapshot

Co-authored-by: Taylor Jones <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 8, 2021
1 parent 80ee23c commit a8a128c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,12 @@ Map {
"type": "string",
},
"selectorsFloatingMenus": Object {
"type": "string",
"args": Array [
Object {
"type": "string",
},
],
"type": "arrayOf",
},
"size": Object {
"args": Array [
Expand Down
3 changes: 2 additions & 1 deletion packages/react/src/components/ComposedModal/ComposedModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default class ComposedModal extends Component {
/**
* Specify the CSS selectors that match the floating menus
*/
selectorsFloatingMenus: PropTypes.string,
selectorsFloatingMenus: PropTypes.arrayOf(PropTypes.string),

/**
* Specify the size variant.
Expand Down Expand Up @@ -234,6 +234,7 @@ export default class ComposedModal extends Component {
danger,
preventCloseOnClickOutside, // eslint-disable-line
selectorPrimaryFocus, // eslint-disable-line
selectorsFloatingMenus, // eslint-disable-line
size,
...other
} = this.props;
Expand Down
17 changes: 8 additions & 9 deletions packages/react/src/internal/wrapFocus.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@ const { prefix } = settings;
* @param {string[]} selectorsFloatingMenus The CSS selectors that matches floating menus.
* @returns {boolean} `true` of the given `node` is in a floating menu.
*/
function elementOrParentIsFloatingMenu(
node,
selectorsFloatingMenus = [
`.${prefix}--overflow-menu-options`,
`.${prefix}--tooltip`,
'.flatpickr-calendar',
]
) {
function elementOrParentIsFloatingMenu(node, selectorsFloatingMenus = []) {
if (node && typeof node.closest === 'function') {
return selectorsFloatingMenus.some((selector) => node.closest(selector));
const allSelectorsFloatingMenus = [
`.${prefix}--overflow-menu-options`,
`.${prefix}--tooltip`,
'.flatpickr-calendar',
...selectorsFloatingMenus,
];
return allSelectorsFloatingMenus.some((selector) => node.closest(selector));
}
}

Expand Down

0 comments on commit a8a128c

Please sign in to comment.