@esfaenza/es-table 20.3.15 → 20.3.16

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.
@@ -6630,6 +6630,9 @@ class EsTable2Component {
6630
6630
  left: Math.min(s.a.c, s.f.c), right: Math.max(s.a.c, s.f.c)
6631
6631
  };
6632
6632
  }, ...(ngDevMode ? [{ debugName: "rangeRect" }] : []));
6633
+ /** true se il mousedown corrente è un click sulla singola cella già selezionata
6634
+ * (→ un click senza trascinamento la deseleziona) */
6635
+ this.rangeClickToggle = false;
6633
6636
  /** Avviso transitorio mostrato in un piccolo toast (es. incolla incompatibile) */
6634
6637
  this.notice = signal(null, ...(ngDevMode ? [{ debugName: "notice" }] : []));
6635
6638
  this.noticeTimer = null;
@@ -7394,6 +7397,11 @@ class EsTable2Component {
7394
7397
  // Una sola selezione alla volta: avviare un range azzera l'eventuale selezione di riga
7395
7398
  if (this.hasSelection)
7396
7399
  this.clearSelection();
7400
+ // Se ri-clicco l'unica cella già selezionata (range 1×1 su questa cella), un
7401
+ // click senza drag la deseleziona (gestito nel mouseup).
7402
+ const prev = this.rangeSel();
7403
+ this.rangeClickToggle = !!prev &&
7404
+ prev.a.r === co.r && prev.a.c === co.c && prev.f.r === co.r && prev.f.c === co.c;
7397
7405
  this.rangeDragging.set(true);
7398
7406
  this.rangeSel.set({ a: co, f: co });
7399
7407
  this.clearTextSelection();
@@ -7413,12 +7421,22 @@ class EsTable2Component {
7413
7421
  return;
7414
7422
  if (s.f.r === co.r && s.f.c === co.c)
7415
7423
  return; // nessun cambiamento → niente ricalcolo (no debounce necessario)
7424
+ this.rangeClickToggle = false; // è un drag, non un click di toggle
7416
7425
  this.rangeSel.set({ a: s.a, f: co });
7417
7426
  this.clearTextSelection();
7418
7427
  this.cdr.markForCheck();
7419
7428
  }
7420
- onDocMouseUp() { if (this.rangeDragging())
7421
- this.rangeDragging.set(false); }
7429
+ onDocMouseUp() {
7430
+ if (!this.rangeDragging())
7431
+ return;
7432
+ this.rangeDragging.set(false);
7433
+ // click (nessun drag) sull'unica cella già selezionata → deseleziona
7434
+ if (this.rangeClickToggle) {
7435
+ this.rangeClickToggle = false;
7436
+ this.rangeSel.set(null);
7437
+ this.cdr.markForCheck();
7438
+ }
7439
+ }
7422
7440
  flashNotice(msg) {
7423
7441
  this.notice.set(msg);
7424
7442
  this.cdr.markForCheck();