handle second issue

This commit is contained in:
Ayoub Ait Lachgar 2024-01-05 09:08:12 +01:00
parent b4ebd69279
commit 7889b4d54a
1 changed files with 10 additions and 7 deletions

View File

@ -1,7 +1,7 @@
const LOW_PRIORITY = 800; const LOW_PRIORITY = 800;
export default function PropertiesPanelProvider(propertiesPanel, eventBus) { export default function PropertiesPanelProvider(propertiesPanel, eventBus) {
let elId; let el;
// eventBus.on('propertiesPanel.providersChanged', function (event) { // eventBus.on('propertiesPanel.providersChanged', function (event) {
// console.log('------------------- propertiesPanel.providersChanged', event); // console.log('------------------- propertiesPanel.providersChanged', event);
@ -21,10 +21,12 @@ export default function PropertiesPanelProvider(propertiesPanel, eventBus) {
this.getGroups = function (element) { this.getGroups = function (element) {
return function (groups) { return function (groups) {
// console.log('PropertiesPanelProvider -> getGroups: ', groups, propertiesPanel, element); // Only render when : el is undefined (editor onload state) or user selects new element or user changes the type of a selected element
// Only render the properties panel once per element if (!el || element.id !== el.id || (element.type !== el.type && element.id === el.id)) {
if (element.id !== elId || !elId) { el = {
elId = element.id; id: element.id,
type: element.type
}
this.render(groups); this.render(groups);
} }
return groups; return groups;
@ -39,6 +41,7 @@ PropertiesPanelProvider.$inject = ['propertiesPanel', 'eventBus'];
PropertiesPanelProvider.prototype.render = function (groups) { PropertiesPanelProvider.prototype.render = function (groups) {
setTimeout(() => { setTimeout(() => {
console.log('Render ;;;')
const propertiesPanelContainer = document.querySelector('.bio-properties-panel-container'); const propertiesPanelContainer = document.querySelector('.bio-properties-panel-container');
if (!propertiesPanelContainer) return; if (!propertiesPanelContainer) return;
@ -63,12 +66,12 @@ PropertiesPanelProvider.prototype.render = function (groups) {
arrow.classList.remove('bio-properties-panel-arrow-right'); arrow.classList.remove('bio-properties-panel-arrow-right');
// Handles the first click, to prevent the bpmn js library from handling it instead // Handles the first click, to prevent the bpmn js library from handling it instead
header.addEventListener('click', function(event) { header.addEventListener('click', function() {
if (isFirstClick) { if (isFirstClick) {
header.click(); header.click();
isFirstClick = false; isFirstClick = false;
} }
}, { once: true }); });
} }
} }