@syncfusion/ej2-splitbuttons 19.3.43 → 19.3.48

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.
@@ -393,13 +393,23 @@ let DropDownButton = class DropDownButton extends Component {
393
393
  }
394
394
  this.appendArrowSpan();
395
395
  this.setActiveElem([this.element]);
396
- if (this.target || !this.createPopupOnClick) {
396
+ if ((this.target && !this.isColorPicker()) || !this.createPopupOnClick) {
397
397
  this.createPopup();
398
398
  }
399
399
  else {
400
400
  this.isPopupCreated = false;
401
401
  }
402
402
  }
403
+ isColorPicker() {
404
+ if (!this.element) {
405
+ return false;
406
+ }
407
+ const prevElem = this.element.previousSibling;
408
+ if (prevElem && prevElem.classList && prevElem.classList.contains('e-split-colorpicker')) {
409
+ return true;
410
+ }
411
+ return false;
412
+ }
403
413
  appendArrowSpan() {
404
414
  this.element.appendChild(this.createElement('span', {
405
415
  className: 'e-btn-icon e-icons ' + 'e-icon-' + (this.cssClass.indexOf(classNames.VERTICAL) > -1
@@ -450,6 +460,7 @@ let DropDownButton = class DropDownButton extends Component {
450
460
  attrList.forEach((key) => {
451
461
  this.element.removeAttribute(key);
452
462
  });
463
+ this.popupUnWireEvents();
453
464
  this.destroyPopup();
454
465
  this.isPopupCreated = false;
455
466
  if (!this.disabled) {
@@ -491,16 +502,33 @@ let DropDownButton = class DropDownButton extends Component {
491
502
  }
492
503
  wireEvents() {
493
504
  this.delegateMousedownHandler = this.mousedownHandler.bind(this);
494
- EventHandler.add(document, 'mousedown touchstart', this.delegateMousedownHandler, this);
505
+ if (!this.createPopupOnClick) {
506
+ EventHandler.add(document, 'mousedown touchstart', this.delegateMousedownHandler, this);
507
+ }
495
508
  EventHandler.add(this.element, 'click', this.clickHandler, this);
496
509
  EventHandler.add(this.element, 'keydown', this.keyBoardHandler, this);
497
510
  }
498
511
  popupWireEvents() {
499
512
  const popupElement = this.getPopUpElement();
500
- EventHandler.add(popupElement, 'click', this.clickHandler, this);
501
- EventHandler.add(popupElement, 'keydown', this.keyBoardHandler, this);
513
+ if (this.createPopupOnClick) {
514
+ EventHandler.add(document, 'mousedown touchstart', this.delegateMousedownHandler, this);
515
+ }
516
+ if (popupElement) {
517
+ EventHandler.add(popupElement, 'click', this.clickHandler, this);
518
+ EventHandler.add(popupElement, 'keydown', this.keyBoardHandler, this);
519
+ }
502
520
  this.rippleFn = rippleEffect(popupElement, { selector: '.' + classNames.ITEM });
503
521
  }
522
+ popupUnWireEvents() {
523
+ const popupElement = this.getPopUpElement();
524
+ if (this.createPopupOnClick) {
525
+ EventHandler.remove(document, 'mousedown touchstart', this.delegateMousedownHandler);
526
+ }
527
+ if (popupElement && popupElement.parentElement) {
528
+ EventHandler.remove(popupElement, 'click', this.clickHandler);
529
+ EventHandler.remove(popupElement, 'keydown', this.keyBoardHandler);
530
+ }
531
+ }
504
532
  /**
505
533
  * Handles the keyboard interactions.
506
534
  *
@@ -569,7 +597,7 @@ let DropDownButton = class DropDownButton extends Component {
569
597
  clickHandler(e) {
570
598
  const trgt = e.target;
571
599
  if (closest(trgt, '[id="' + this.element.id + '"]')) {
572
- if (!this.createPopupOnClick || this.target) {
600
+ if (!this.createPopupOnClick || (this.target && !this.isColorPicker())) {
573
601
  if (this.getPopUpElement().classList.contains('e-popup-close')) {
574
602
  this.openPopUp(e);
575
603
  }
@@ -631,6 +659,7 @@ let DropDownButton = class DropDownButton extends Component {
631
659
  }
632
660
  this.trigger('beforeClose', beforeCloseArgs, (observedArgs) => {
633
661
  if (!observedArgs.cancel) {
662
+ this.popupUnWireEvents();
634
663
  const ul = this.getULElement();
635
664
  const selectedLi = ul.querySelector('.e-selected');
636
665
  if (selectedLi) {
@@ -647,7 +676,7 @@ let DropDownButton = class DropDownButton extends Component {
647
676
  if (!this.target && ul) {
648
677
  detach(ul);
649
678
  }
650
- if (!this.target) {
679
+ if (!this.target || this.isColorPicker()) {
651
680
  if (this.createPopupOnClick) {
652
681
  this.destroyPopup();
653
682
  }
@@ -659,7 +688,9 @@ let DropDownButton = class DropDownButton extends Component {
659
688
  });
660
689
  }
661
690
  unWireEvents() {
662
- EventHandler.remove(document, 'mousedown touchstart', this.delegateMousedownHandler);
691
+ if (!this.createPopupOnClick) {
692
+ EventHandler.remove(document, 'mousedown touchstart', this.delegateMousedownHandler);
693
+ }
663
694
  EventHandler.remove(this.element, 'click', this.clickHandler);
664
695
  EventHandler.remove(this.element, 'keydown', this.keyBoardHandler);
665
696
  if (this.isPopupCreated) {