Skip to content

Commit 40db335

Browse files
committed
test(range): emit ionFocus only once per focus event
1 parent 5e5efaf commit 40db335

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

core/src/components/range/test/basic/range.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ describe('range: dual knobs focus management', () => {
9595
expect(knobB.classList.contains('ion-focused')).toBe(false);
9696
});
9797

98-
it('should emit ionFocus when any knob receives focus', async () => {
98+
it('should emit ionFocus when any knob receives focus but only once until blur', async () => {
9999
const page = await newSpecPage({
100100
components: [Range],
101101
html: `
@@ -107,18 +107,20 @@ describe('range: dual knobs focus management', () => {
107107
const range = page.body.querySelector('ion-range')!;
108108
await page.waitForChanges();
109109

110-
let focusEventFired = false;
110+
let focusEventFiredCount = 0;
111111
range.addEventListener('ionFocus', () => {
112-
focusEventFired = true;
112+
focusEventFiredCount++;
113113
});
114114

115115
const knobA = range.shadowRoot!.querySelector('.range-knob-a') as HTMLElement;
116+
const knobB = range.shadowRoot!.querySelector('.range-knob-b') as HTMLElement;
116117

117118
// Focus knob A
118119
knobA.dispatchEvent(new Event('focus'));
120+
knobB.dispatchEvent(new Event('focus'));
119121
await page.waitForChanges();
120122

121-
expect(focusEventFired).toBe(true);
123+
expect(focusEventFiredCount).toBe(1);
122124
});
123125

124126
it('should emit ionBlur when focus leaves the range completely', async () => {

0 commit comments

Comments
 (0)