@kubex/zinc 2.0.0 → 2.0.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubex/zinc",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "A collection of web components for building web applications based off of @shoelace-style/Shoelace",
5
5
  "keywords": [
6
6
  "web components",
@@ -529,6 +529,9 @@ zn-style.zn-muted {
529
529
 
530
530
  .table tr .table__head--reorderable {
531
531
  cursor: grab;
532
+ // A press here is a drag; starting a text selection would sweep it across the table
533
+ user-select: none;
534
+ -webkit-user-select: none;
532
535
 
533
536
  &:active {
534
537
  cursor: grabbing;
@@ -99,6 +99,7 @@ export class ReorderController implements ReactiveController {
99
99
  private shield: HTMLElement | null = null;
100
100
  private scroller: Element | null = null;
101
101
  private scrollFrame = 0;
102
+ private pressRoot: Node | null = null;
102
103
 
103
104
  constructor(host: ReorderHost, options: ReorderOptions = {}) {
104
105
  this.host = host;
@@ -204,7 +205,11 @@ export class ReorderController implements ReactiveController {
204
205
  window.addEventListener('pointercancel', this.onPointerCancel, true);
205
206
  window.addEventListener('touchmove', this.onTouchMove, {capture: true, passive: false});
206
207
  // A link or image in the row would otherwise start a native drag and take the pointer
207
- window.addEventListener('dragstart', this.onNativeDragStart, true);
208
+ window.addEventListener('dragstart', this.cancel, true);
209
+ // The press would otherwise also start a text selection that sweeps the page as it drags; selectstart isn't
210
+ // composed, so it's caught in the row's own tree
211
+ this.pressRoot = this.host.reorderRow(key)!.getRootNode();
212
+ this.pressRoot.addEventListener('selectstart', this.cancel, true);
208
213
  }
209
214
 
210
215
  private onPointerMove = (event: PointerEvent) => {
@@ -246,7 +251,7 @@ export class ReorderController implements ReactiveController {
246
251
  if (this.isDragging) event.preventDefault();
247
252
  };
248
253
 
249
- private onNativeDragStart = (event: DragEvent) => {
254
+ private cancel = (event: Event) => {
250
255
  event.preventDefault();
251
256
  };
252
257
 
@@ -463,7 +468,9 @@ export class ReorderController implements ReactiveController {
463
468
  window.removeEventListener('pointerup', this.onPointerUp, true);
464
469
  window.removeEventListener('pointercancel', this.onPointerCancel, true);
465
470
  window.removeEventListener('touchmove', this.onTouchMove, true);
466
- window.removeEventListener('dragstart', this.onNativeDragStart, true);
471
+ window.removeEventListener('dragstart', this.cancel, true);
472
+ this.pressRoot?.removeEventListener('selectstart', this.cancel, true);
473
+ this.pressRoot = null;
467
474
  }
468
475
 
469
476
  /** Shows the new order, sliding each row from its old position. */