Skip to content

Commit e614ed6

Browse files
committed
fix(ui): pDropdown trigger closes on 2nd click
1 parent dba6679 commit e614ed6

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/client/components/PDropdown/index.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import clsx from 'clsx'
1818

1919
class PDropDown extends React.Component {
2020
dropRef = createRef()
21+
pTriggerRef = null
2122

2223
constructor (props) {
2324
super(props)
@@ -28,7 +29,7 @@ class PDropDown extends React.Component {
2829

2930
hideDropdownOnMouseUp (e) {
3031
if (this.dropRef.current) {
31-
if (!this.dropRef.current.contains(e.target)) {
32+
if (!this.dropRef.current.contains(e.target) && !this.pTriggerRef.contains(e.target)) {
3233
document.removeEventListener('mouseup', this.hideDropdownOnMouseUp)
3334
this.dropRef.current.classList.remove('pDropOpen')
3435
}
@@ -48,6 +49,8 @@ class PDropDown extends React.Component {
4849
return true
4950
}
5051

52+
this.pTriggerRef = pTrigger
53+
5154
if (this.dropRef.current) {
5255
const ref = this.dropRef.current
5356
if (ref.classList.contains('pDropOpen')) {

src/public/js/modules/helpers.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,11 +1172,9 @@ define([
11721172
}
11731173

11741174
helpers.hideAllpDropDowns = function () {
1175-
$('[data-notifications]').each(function () {
1176-
var drop = $('#' + $(this).attr('data-notifications'))
1177-
if (drop.hasClass('pDropOpen')) {
1178-
drop.removeClass('pDropOpen')
1179-
}
1175+
$('.p-dropdown').each(function () {
1176+
const $drop = $(this)
1177+
if ($drop.hasClass('pDropOpen')) $drop.removeClass('pDropOpen')
11801178
})
11811179
}
11821180

0 commit comments

Comments
 (0)