Skip to content

Commit a8a128c

Browse files
dcwarwicktay1orjoneskodiakhq[bot]
authored
fix(ComposedModal): Address several problems with selectorsFloatingMenus 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 <tay1orjones@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 80ee23c commit a8a128c

3 files changed

Lines changed: 16 additions & 11 deletions

File tree

packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,12 @@ Map {
762762
"type": "string",
763763
},
764764
"selectorsFloatingMenus": Object {
765-
"type": "string",
765+
"args": Array [
766+
Object {
767+
"type": "string",
768+
},
769+
],
770+
"type": "arrayOf",
766771
},
767772
"size": Object {
768773
"args": Array [

packages/react/src/components/ComposedModal/ComposedModal.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export default class ComposedModal extends Component {
9191
/**
9292
* Specify the CSS selectors that match the floating menus
9393
*/
94-
selectorsFloatingMenus: PropTypes.string,
94+
selectorsFloatingMenus: PropTypes.arrayOf(PropTypes.string),
9595

9696
/**
9797
* Specify the size variant.
@@ -234,6 +234,7 @@ export default class ComposedModal extends Component {
234234
danger,
235235
preventCloseOnClickOutside, // eslint-disable-line
236236
selectorPrimaryFocus, // eslint-disable-line
237+
selectorsFloatingMenus, // eslint-disable-line
237238
size,
238239
...other
239240
} = this.props;

packages/react/src/internal/wrapFocus.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,15 @@ const { prefix } = settings;
2020
* @param {string[]} selectorsFloatingMenus The CSS selectors that matches floating menus.
2121
* @returns {boolean} `true` of the given `node` is in a floating menu.
2222
*/
23-
function elementOrParentIsFloatingMenu(
24-
node,
25-
selectorsFloatingMenus = [
26-
`.${prefix}--overflow-menu-options`,
27-
`.${prefix}--tooltip`,
28-
'.flatpickr-calendar',
29-
]
30-
) {
23+
function elementOrParentIsFloatingMenu(node, selectorsFloatingMenus = []) {
3124
if (node && typeof node.closest === 'function') {
32-
return selectorsFloatingMenus.some((selector) => node.closest(selector));
25+
const allSelectorsFloatingMenus = [
26+
`.${prefix}--overflow-menu-options`,
27+
`.${prefix}--tooltip`,
28+
'.flatpickr-calendar',
29+
...selectorsFloatingMenus,
30+
];
31+
return allSelectorsFloatingMenus.some((selector) => node.closest(selector));
3332
}
3433
}
3534

0 commit comments

Comments
 (0)