Skip to content

Commit

Permalink
fix: action list modal opening
Browse files Browse the repository at this point in the history
  • Loading branch information
Soare-Robert-Daniel committed May 27, 2024
1 parent 72a168a commit 1258e3e
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions js/ActionPopup/action-popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ const ActionModal = () => {
});
}, []);

useEffect(() => {
document.addEventListener( 'click', exitModalOnOutsideClick );
return () => {
document.removeEventListener( 'click', exitModalOnOutsideClick );
};
}, [isVisible] );

Check warning on line 58 in js/ActionPopup/action-popup.js

View workflow job for this annotation

GitHub Actions / npm (18.x)

React Hook useEffect has a missing dependency: 'exitModalOnOutsideClick'. Either include it or remove the dependency array

const handleChange = (args) => {
let id = args.index;
delete args.index;
Expand Down Expand Up @@ -179,14 +186,12 @@ const ActionModal = () => {
};

// Close the popup when click on outside the modal.
document.body.addEventListener( 'click', function( e ) {
if ( isVisible ) {
if ( e.target.closest( '.popover-action-list' ) ) {
return;
}
toggleVisible(false);
const exitModalOnOutsideClick = ( e ) => {
if ( ! isVisible || ! e.target.closest( '.fz-action-popup' ) ) {
return;
}
} );
toggleVisible( false );
};

// Click to open action popup.
document.querySelectorAll( '[data-action_popup]' ).forEach( actionItem => {
Expand Down Expand Up @@ -267,7 +272,7 @@ const ActionModal = () => {
<p>{ __( 'If no action is needed, continue with using the original tag by clicking on the Save Actions button.', 'feedzy-rss-feeds' ) }</p>
</div>
) }

{action.length > 0 && ( <Actions data={action} removeCallback={removeAction} onChangeHandler={handleChange} onSortEnd={onSortEnd} useDragHandle lockAxis="y" helperClass="draggable-item" distance={1} lockToContainerEdges={true} lockOffset="0%"/> )}

<div className="fz-action-btn">
Expand Down Expand Up @@ -360,4 +365,4 @@ const ActionModal = () => {
ReactDOM.render(
<ActionModal />,
document.querySelector('#fz-action-popup')
);
);

0 comments on commit 1258e3e

Please sign in to comment.