diff --git a/awx/ui_next/src/components/DataListToolbar/DataListToolbar.jsx b/awx/ui_next/src/components/DataListToolbar/DataListToolbar.jsx index 1ddfb57df6..d8c84233c7 100644 --- a/awx/ui_next/src/components/DataListToolbar/DataListToolbar.jsx +++ b/awx/ui_next/src/components/DataListToolbar/DataListToolbar.jsx @@ -1,4 +1,4 @@ -import React, { Fragment, useState } from 'react'; +import React, { Fragment, useEffect, useState } from 'react'; import PropTypes from 'prop-types'; import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; @@ -43,6 +43,7 @@ function DataListToolbar({ }) { const showExpandCollapse = onCompact && onExpand; const [kebabIsOpen, setKebabIsOpen] = useState(false); + const [kebabModalIsOpen, setKebabkebabModalIsOpen] = useState(false); const [advancedSearchShown, setAdvancedSearchShown] = useState(false); const onShowAdvancedSearch = shown => { @@ -50,6 +51,12 @@ function DataListToolbar({ setKebabIsOpen(false); }; + useEffect(() => { + if (!kebabModalIsOpen) { + setKebabIsOpen(false); + } + }, [kebabModalIsOpen]); + return ( - } - isOpen={kebabIsOpen} - isPlain - dropdownItems={additionalControls.map(control => { - return ( - - {control} - - ); - })} - /> + setKebabkebabModalIsOpen(isOpen), + }} + > + { + if (!kebabModalIsOpen) { + setKebabIsOpen(isOpen); + } + }} + /> + } + isOpen={kebabIsOpen} + isPlain + dropdownItems={additionalControls} + /> + )} {!advancedSearchShown && ( diff --git a/awx/ui_next/src/components/JobList/JobList.jsx b/awx/ui_next/src/components/JobList/JobList.jsx index d02b8b7f60..c08401acbc 100644 --- a/awx/ui_next/src/components/JobList/JobList.jsx +++ b/awx/ui_next/src/components/JobList/JobList.jsx @@ -276,6 +276,7 @@ function JobList({ i18n, defaultParams, showTypeColumn = false }) { pluralizedItemName="Jobs" />, , diff --git a/awx/ui_next/src/components/JobList/JobListCancelButton.jsx b/awx/ui_next/src/components/JobList/JobListCancelButton.jsx index a4fbc197b4..1e04886de4 100644 --- a/awx/ui_next/src/components/JobList/JobListCancelButton.jsx +++ b/awx/ui_next/src/components/JobList/JobListCancelButton.jsx @@ -62,14 +62,17 @@ function JobListCancelButton({ i18n, jobsToCancel, onCancel }) { return ( - {({ isKebabified }) => ( + {({ isKebabified, onKebabModalChange }) => ( <> {isKebabified ? ( setIsModalOpen(true)} + component="button" + onClick={() => { + onKebabModalChange(true); + setIsModalOpen(true); + }} > {cancelJobText} @@ -92,14 +95,24 @@ function JobListCancelButton({ i18n, jobsToCancel, onCancel }) { variant="danger" title={cancelJobText} isOpen={isModalOpen} - onClose={() => setIsModalOpen(false)} + onClose={() => { + if (isKebabified) { + onKebabModalChange(false); + } + setIsModalOpen(false); + }} actions={[ , @@ -108,7 +121,12 @@ function JobListCancelButton({ i18n, jobsToCancel, onCancel }) { key="cancel" variant="secondary" aria-label={i18n._(t`Return`)} - onClick={() => setIsModalOpen(false)} + onClick={() => { + if (isKebabified) { + onKebabModalChange(false); + } + setIsModalOpen(false); + }} > {i18n._(t`Return`)} , diff --git a/awx/ui_next/src/components/PaginatedDataList/ToolbarDeleteButton.jsx b/awx/ui_next/src/components/PaginatedDataList/ToolbarDeleteButton.jsx index 7be476dfc1..4e9b44ae70 100644 --- a/awx/ui_next/src/components/PaginatedDataList/ToolbarDeleteButton.jsx +++ b/awx/ui_next/src/components/PaginatedDataList/ToolbarDeleteButton.jsx @@ -140,14 +140,17 @@ class ToolbarDeleteButton extends React.Component { // See: https://github.com/patternfly/patternfly-react/issues/1894 return ( - {({ isKebabified }) => ( + {({ isKebabified, onKebabModalChange }) => ( {isKebabified ? ( { + onKebabModalChange(true); + this.handleConfirmDelete(); + }} > {i18n._(t`Delete`)} @@ -170,13 +173,23 @@ class ToolbarDeleteButton extends React.Component { variant="danger" title={modalTitle} isOpen={isModalOpen} - onClose={this.handleCancelDelete} + onClose={() => { + if (isKebabified) { + onKebabModalChange(false); + } + this.handleCancelDelete(); + }} actions={[ , @@ -184,7 +197,12 @@ class ToolbarDeleteButton extends React.Component { key="cancel" variant="secondary" aria-label={i18n._(t`cancel delete`)} - onClick={this.handleCancelDelete} + onClick={() => { + if (isKebabified) { + onKebabModalChange(false); + } + this.handleCancelDelete(); + }} > {i18n._(t`Cancel`)} ,