@descope/web-components-ui 1.0.95 → 1.0.96

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.esm.js CHANGED
@@ -423,6 +423,35 @@ const draggableMixin = (superclass) =>
423
423
  }
424
424
  }
425
425
 
426
+ get #isDraggable() {
427
+ return this.hasAttribute('draggable') && this.getAttribute('draggable') !== 'false'
428
+ }
429
+
430
+ init() {
431
+
432
+ // because we are delegating the focus from the outer component,
433
+ // the D&D is not working well in the page editor
434
+ // in order to solve it we are making the inner component focusable on mouse down
435
+ // and removing it on complete
436
+ this.addEventListener('mousedown', (e) => {
437
+ if (this.#isDraggable) {
438
+ this.baseElement.setAttribute('tabindex', '-1');
439
+
440
+ const onComplete = () => {
441
+ this.baseElement.removeAttribute('tabindex');
442
+
443
+ e.target.removeEventListener('mouseup', onComplete);
444
+ e.target.removeEventListener('dragend', onComplete);
445
+ };
446
+
447
+ e.target.addEventListener('mouseup', onComplete, { once: true });
448
+ e.target.addEventListener('dragend', onComplete, { once: true });
449
+ }
450
+ });
451
+
452
+ super.init?.();
453
+ }
454
+
426
455
  attributeChangedCallback(attrName, oldValue, newValue) {
427
456
  super.attributeChangedCallback?.(attrName, oldValue, newValue);
428
457
  if (attrName === 'draggable') {