@kubex/zinc 1.1.109 → 1.1.110

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.
@@ -268,6 +268,7 @@ export default class ZnPopup extends ZincElement {
268
268
  if (!this.anchorEl) {
269
269
  return;
270
270
  }
271
+ this.cleanup?.();
271
272
  this.cleanup = autoUpdate(this.anchorEl, this.popup, () => {
272
273
  this.reposition();
273
274
  });
@@ -406,7 +407,9 @@ export default class ZnPopup extends ZincElement {
406
407
 
407
408
  if (!this.popup?.isConnected) return;
408
409
 
409
- this.popup.showPopover();
410
+ if (!this.popup.matches(':popover-open')) {
411
+ this.popup.showPopover();
412
+ }
410
413
 
411
414
  if (this.arrow) {
412
415
  const arrowX = middlewareData.arrow!.x;
@@ -537,7 +540,7 @@ export default class ZnPopup extends ZincElement {
537
540
  <div
538
541
  id="popup"
539
542
  part="popup"
540
- popover
543
+ popover="manual"
541
544
  class="${classMap({
542
545
  popup: true,
543
546
  'popup--active': this.active,
@@ -1,5 +1,5 @@
1
1
  import '../../../dist/zn.min.js';
2
- import {expect, fixture, html} from '@open-wc/testing';
2
+ import {expect, fixture, html, waitUntil} from '@open-wc/testing';
3
3
  import type ZnOption from '../option/option.component';
4
4
  import type ZnSelect from './select.component';
5
5
 
@@ -824,4 +824,44 @@ describe('<zn-select>', () => {
824
824
  expect(getComputedStyle(addRow).fontSize).to.equal('11px');
825
825
  });
826
826
  });
827
+
828
+ it('does not flicker the open listbox when a second select is opened', async () => {
829
+ const wrapper = await fixture(html`
830
+ <div>
831
+ <zn-select id="first">
832
+ <zn-option value="apple">Apple</zn-option>
833
+ <zn-option value="banana">Banana</zn-option>
834
+ </zn-select>
835
+ <zn-select id="second">
836
+ <zn-option value="cherry">Cherry</zn-option>
837
+ <zn-option value="date">Date</zn-option>
838
+ </zn-select>
839
+ </div>
840
+ `);
841
+
842
+ const first = wrapper.querySelector<ZnSelect>('#first')!;
843
+ const second = wrapper.querySelector<ZnSelect>('#second')!;
844
+ await Promise.all([first.updateComplete, second.updateComplete]);
845
+
846
+ const popoverOf = (el: ZnSelect) =>
847
+ el.shadowRoot!.querySelector('zn-popup')!.shadowRoot!.querySelector<HTMLElement>('#popup')!;
848
+
849
+ const states: string[] = [];
850
+ popoverOf(first).addEventListener('beforetoggle', (event: Event) =>
851
+ states.push((event as ToggleEvent).newState));
852
+
853
+ await first.show();
854
+ states.length = 0;
855
+
856
+ // Mimic a click on the second select: the document mousedown closes the first, the combobox
857
+ // mousedown opens the second
858
+ document.dispatchEvent(new MouseEvent('mousedown', {bubbles: true, composed: true}));
859
+ second.shadowRoot!.querySelector('.select__combobox')!
860
+ .dispatchEvent(new MouseEvent('mousedown', {bubbles: true, composed: true}));
861
+ await second.updateComplete;
862
+ await waitUntil(() => !first.open && states.includes('closed'));
863
+
864
+ expect(states).to.deep.equal(['closed']);
865
+ expect(popoverOf(second).matches(':popover-open')).to.be.true;
866
+ });
827
867
  });