jsdialog: use open/close instead of toggle for dropdowns

This helps us to be in sync with core especially with
problematic dropdowns like:
Sidebar in shape context -> Line Panel -> Line Width
This will close and not reopen the popup when we click outside.

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I4daf90f2611f6caa922022e1cc6e248f6a62d02f
This commit is contained in:
Szymon Kłos 2022-06-28 13:15:10 +02:00 committed by pedropintosilva
parent 7c45f7a468
commit 0833ec6489

View file

@ -2593,9 +2593,19 @@ L.Control.JSDialogBuilder = L.Control.extend({
var arrowbackground = L.DomUtil.create('div', 'arrowbackground', div);
var arrow = L.DomUtil.create('i', 'unoarrow', arrowbackground);
controls['arrow'] = arrow;
var menuIsOpened = false;
$(arrowbackground).click(function (event) {
if (!$(div).hasClass('disabled')) {
builder.callback('toolbox', 'togglemenu', parentContainer, data.command, builder);
if (menuIsOpened) {
builder.callback('toolbox', 'closemenu', parentContainer, data.command, builder);
menuIsOpened = false;
$(div).removeClass('menu-opened');
} else {
menuIsOpened = true;
builder.callback('toolbox', 'openmenu', parentContainer, data.command, builder);
$(div).addClass('menu-opened');
}
event.stopPropagation();
}
});