diff --git a/src/client/components/PDropdown/index.jsx b/src/client/components/PDropdown/index.jsx index b1deb4212..acc90fb94 100644 --- a/src/client/components/PDropdown/index.jsx +++ b/src/client/components/PDropdown/index.jsx @@ -18,6 +18,7 @@ import clsx from 'clsx' class PDropDown extends React.Component { dropRef = createRef() + pTriggerRef = null constructor (props) { super(props) @@ -28,7 +29,7 @@ class PDropDown extends React.Component { hideDropdownOnMouseUp (e) { if (this.dropRef.current) { - if (!this.dropRef.current.contains(e.target)) { + if (!this.dropRef.current.contains(e.target) && !this.pTriggerRef.contains(e.target)) { document.removeEventListener('mouseup', this.hideDropdownOnMouseUp) this.dropRef.current.classList.remove('pDropOpen') } @@ -48,6 +49,8 @@ class PDropDown extends React.Component { return true } + this.pTriggerRef = pTrigger + if (this.dropRef.current) { const ref = this.dropRef.current if (ref.classList.contains('pDropOpen')) { diff --git a/src/public/js/modules/helpers.js b/src/public/js/modules/helpers.js index ac8b60072..d22803f25 100644 --- a/src/public/js/modules/helpers.js +++ b/src/public/js/modules/helpers.js @@ -1172,11 +1172,9 @@ define([ } helpers.hideAllpDropDowns = function () { - $('[data-notifications]').each(function () { - var drop = $('#' + $(this).attr('data-notifications')) - if (drop.hasClass('pDropOpen')) { - drop.removeClass('pDropOpen') - } + $('.p-dropdown').each(function () { + const $drop = $(this) + if ($drop.hasClass('pDropOpen')) $drop.removeClass('pDropOpen') }) }