@node-projects/web-component-designer-widgets-wunderbaum 0.1.20 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,7 @@ export declare class TreeViewExtended extends BaseCustomWebComponentConstructorA
18
18
  _showHideAtRunTimeState(img: HTMLImageElement, designItem: IDesignItem): void;
19
19
  _switchHideAtRunTimeState(img: HTMLImageElement, designItem: IDesignItem): void;
20
20
  showDesignItemContextMenu(designItem: IDesignItem, event: MouseEvent): ContextMenu;
21
+ selectedFromTree: boolean;
21
22
  ready(): Promise<void>;
22
23
  _recomputeRunning: any;
23
24
  _recomputeRequestedAgain: any;
@@ -131,6 +131,7 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
131
131
  let ctxMnu = ContextMenu.show(mnuItems, event);
132
132
  return ctxMnu;
133
133
  }
134
+ selectedFromTree = false;
134
135
  async ready() {
135
136
  this._tree = new Wunderbaum({
136
137
  ...defaultOptions,
@@ -141,6 +142,10 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
141
142
  let node = e.node;
142
143
  let designItem = node.data.ref;
143
144
  if (designItem) {
145
+ this.selectedFromTree = true;
146
+ setTimeout(() => {
147
+ this.selectedFromTree = false;
148
+ }, 50);
144
149
  if (e.event.ctrlKey) {
145
150
  const sel = [...designItem.instanceServiceContainer.selectionService.selectedElements];
146
151
  const idx = sel.indexOf(designItem);
@@ -294,6 +299,9 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
294
299
  this._contentChangedHandler?.dispose();
295
300
  this._contentChangedHandler = this._instanceServiceContainer.contentService.onContentChanged.on(e => {
296
301
  this.createTree(value.contentService.rootDesignItem);
302
+ setTimeout(() => {
303
+ this._highlight(this._instanceServiceContainer.selectionService.selectedElements);
304
+ }, 20);
297
305
  });
298
306
  this.createTree(value.contentService.rootDesignItem);
299
307
  }
@@ -330,15 +338,19 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
330
338
  this._tree.runWithDeferredUpdate(() => {
331
339
  this._tree.visit((node) => {
332
340
  const flag = activeElements && activeElements.includes(node.data.ref);
333
- node.setSelected(flag);
334
- node.setActive(flag);
335
- if (flag)
336
- node.setFocus(true);
337
- if (flag && !scrolled) {
338
- scrolled = true;
339
- requestAnimationFrame(() => {
340
- node.scrollIntoView();
341
- });
341
+ if (flag != node.selected)
342
+ node.setSelected(flag);
343
+ if (flag != node.isActive())
344
+ node.setActive(flag);
345
+ if (!this.selectedFromTree) {
346
+ if (flag)
347
+ node.setFocus(true);
348
+ if (flag && !scrolled) {
349
+ scrolled = true;
350
+ requestAnimationFrame(() => {
351
+ node.scrollIntoView();
352
+ });
353
+ }
342
354
  }
343
355
  });
344
356
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "description": "web-component-designer addon: Widgets using wunderbaum",
3
3
  "name": "@node-projects/web-component-designer-widgets-wunderbaum",
4
- "version": "0.1.20",
4
+ "version": "0.1.22",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",