Skip to content

Commit

Permalink
fix(ui): pDropdown trigger closes on 2nd click
Browse files Browse the repository at this point in the history
  • Loading branch information
polonel committed Jul 11, 2022
1 parent dba6679 commit e614ed6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/client/components/PDropdown/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import clsx from 'clsx'

class PDropDown extends React.Component {
dropRef = createRef()
pTriggerRef = null

constructor (props) {
super(props)
Expand All @@ -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')
}
Expand All @@ -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')) {
Expand Down
8 changes: 3 additions & 5 deletions src/public/js/modules/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
}

Expand Down

0 comments on commit e614ed6

Please sign in to comment.