@aquera/ngx-smart-table 0.0.12-alpha → 0.0.13-alpha

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.
@@ -3612,6 +3612,7 @@ class NileSelectEditor {
3612
3612
  this.acceptsInitialKeypress = false;
3613
3613
  this.eventListeners = [];
3614
3614
  this.currentOptions = [];
3615
+ this.isInitializing = false; // Flag to prevent immediate close during initialization
3615
3616
  // Handle Observable options
3616
3617
  if (isObservable(options.options)) {
3617
3618
  this.optionsSubscription = options.options.subscribe(opts => {
@@ -3635,6 +3636,8 @@ class NileSelectEditor {
3635
3636
  console.warn('NileSelectEditor requires a container element');
3636
3637
  return;
3637
3638
  }
3639
+ // Set initializing flag to prevent immediate close
3640
+ this.isInitializing = true;
3638
3641
  // Create NileSelect custom element using document.createElement
3639
3642
  this.select = document.createElement('nile-select');
3640
3643
  this.select.className = 'st-cell-editor';
@@ -3656,11 +3659,22 @@ class NileSelectEditor {
3656
3659
  // Focus after render
3657
3660
  setTimeout(() => {
3658
3661
  this.select?.focus();
3659
- this.select?.click();
3660
- // Find the portal div for multi-select click detection
3662
+ // Use the open property to open the dropdown (more reliable than click)
3663
+ if (this.select) {
3664
+ this.select.open = true;
3665
+ }
3666
+ // For multi-select, find the portal div for click detection
3661
3667
  if (this.options.multiple) {
3662
- // Portal div is appended to document body
3663
- this.portalDiv = document.querySelector('.nile-select-portal-append');
3668
+ setTimeout(() => {
3669
+ this.portalDiv = document.querySelector('.nile-select-portal-append');
3670
+ this.isInitializing = false;
3671
+ }, 150);
3672
+ }
3673
+ else {
3674
+ // Clear initializing flag after dropdown has time to open
3675
+ setTimeout(() => {
3676
+ this.isInitializing = false;
3677
+ }, 100);
3664
3678
  }
3665
3679
  }, 0);
3666
3680
  }
@@ -3745,9 +3759,13 @@ class NileSelectEditor {
3745
3759
  if (this.options.pill) {
3746
3760
  this.select.pill = this.options.pill;
3747
3761
  }
3748
- if (this.options.hoist) {
3762
+ if (this.options.hoist !== undefined) {
3749
3763
  this.select.hoist = this.options.hoist;
3750
3764
  }
3765
+ else {
3766
+ // Default hoist to true for all selects to prevent clipping issues in table cells
3767
+ this.select.hoist = true;
3768
+ }
3751
3769
  if (this.options.placement) {
3752
3770
  this.select.placement = this.options.placement;
3753
3771
  }
@@ -3835,6 +3853,10 @@ class NileSelectEditor {
3835
3853
  this.eventListeners.push({ event: 'keydown', handler: keydownHandler });
3836
3854
  // Use nile-change custom event as primary save trigger
3837
3855
  const changeHandler = (e) => {
3856
+ // Ignore change events during initialization (can fire when setting initial value)
3857
+ if (this.isInitializing) {
3858
+ return;
3859
+ }
3838
3860
  const customEvent = e;
3839
3861
  if (validateOnSave && !this.select?.checkValidity()) {
3840
3862
  this.select?.reportValidity();
@@ -3850,6 +3872,10 @@ class NileSelectEditor {
3850
3872
  this.eventListeners.push({ event: 'nile-change', handler: changeHandler });
3851
3873
  // Handle blur as secondary save trigger
3852
3874
  const blurHandler = (e) => {
3875
+ // Ignore blur during initialization
3876
+ if (this.isInitializing) {
3877
+ return;
3878
+ }
3853
3879
  if (validateOnSave && !this.select?.checkValidity()) {
3854
3880
  this.select?.reportValidity();
3855
3881
  return;
@@ -3858,6 +3884,22 @@ class NileSelectEditor {
3858
3884
  };
3859
3885
  this.select.addEventListener('nile-blur', blurHandler);
3860
3886
  this.eventListeners.push({ event: 'nile-blur', handler: blurHandler });
3887
+ // Handle nile-hide event to prevent unwanted closing during initialization
3888
+ const hideHandler = (e) => {
3889
+ // If dropdown closes during initialization, re-open it (for both single and multi-select)
3890
+ if (this.isInitializing) {
3891
+ e.preventDefault();
3892
+ e.stopPropagation();
3893
+ // Re-open the dropdown after a brief delay using the open property
3894
+ setTimeout(() => {
3895
+ if (this.select && this.isInitializing) {
3896
+ this.select.open = true;
3897
+ }
3898
+ }, 10);
3899
+ }
3900
+ };
3901
+ this.select.addEventListener('nile-hide', hideHandler);
3902
+ this.eventListeners.push({ event: 'nile-hide', handler: hideHandler });
3861
3903
  // Handle clear button if enabled
3862
3904
  if (this.options.clearable) {
3863
3905
  const clearHandler = (e) => {
@@ -3898,12 +3940,19 @@ class NileSelectEditor {
3898
3940
  }
3899
3941
  // Otherwise, click is inside - do nothing (dropdown stays open)
3900
3942
  };
3901
- // Add to document with capture phase
3902
- document.addEventListener('click', documentClickHandler, true);
3903
- this.eventListeners.push({
3904
- event: 'document-click',
3905
- handler: documentClickHandler
3906
- });
3943
+ // Delay adding the document click handler to prevent the initial click
3944
+ // (that opened the editor) from immediately triggering it and closing the dropdown
3945
+ // Use 200ms to ensure the dropdown has fully opened
3946
+ setTimeout(() => {
3947
+ // Only add if select still exists (editor not destroyed)
3948
+ if (this.select) {
3949
+ document.addEventListener('click', documentClickHandler, true);
3950
+ this.eventListeners.push({
3951
+ event: 'document-click',
3952
+ handler: documentClickHandler
3953
+ });
3954
+ }
3955
+ }, 200);
3907
3956
  }
3908
3957
  }
3909
3958
  /**
@@ -3924,6 +3973,8 @@ class NileSelectEditor {
3924
3973
  return value;
3925
3974
  }
3926
3975
  destroy() {
3976
+ // Reset initialization flag
3977
+ this.isInitializing = false;
3927
3978
  // Unsubscribe from options Observable
3928
3979
  if (this.optionsSubscription) {
3929
3980
  this.optionsSubscription.unsubscribe();