Skip to content

Commit 6c94946

Browse files
fix: do not include nested child nodes in tabs items (#10043) (#10122)
Co-authored-by: Serhii Kulykov <[email protected]>
1 parent 987d6ed commit 6c94946

File tree

3 files changed

+36
-44
lines changed

3 files changed

+36
-44
lines changed

packages/a11y-base/src/list-mixin.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import { timeOut } from '@vaadin/component-base/src/async.js';
77
import { Debouncer } from '@vaadin/component-base/src/debounce.js';
88
import { getNormalizedScrollLeft, setNormalizedScrollLeft } from '@vaadin/component-base/src/dir-utils.js';
9-
import { getFlattenedElements } from '@vaadin/component-base/src/dom-utils.js';
109
import { SlotObserver } from '@vaadin/component-base/src/slot-observer.js';
1110
import { isElementHidden } from './focus-utils.js';
1211
import { KeyboardDirectionMixin } from './keyboard-direction-mixin.js';
@@ -138,7 +137,7 @@ export const ListMixin = (superClass) =>
138137

139138
const slot = this.shadowRoot.querySelector('slot:not([name])');
140139
this._observer = new SlotObserver(slot, () => {
141-
this._setItems(this._filterItems(getFlattenedElements(this)));
140+
this._setItems(this._filterItems([...this.children]));
142141
});
143142
}
144143

packages/a11y-base/test/list-mixin.test.js

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
keyDownChar,
1313
nextRender,
1414
nextUpdate,
15-
oneEvent,
1615
} from '@vaadin/testing-helpers';
1716
import sinon from 'sinon';
1817
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
@@ -166,47 +165,6 @@ const runTests = (defineHelper, baseMixin) => {
166165
});
167166
});
168167

169-
describe('wrapped list with slotted items', () => {
170-
let wrapper;
171-
172-
beforeEach(async () => {
173-
wrapper = document.createElement('div');
174-
document.body.appendChild(wrapper);
175-
176-
const root = wrapper.attachShadow({ mode: 'open' });
177-
root.innerHTML = `
178-
<${listTag}>
179-
<slot></slot>
180-
</${listTag}>
181-
`;
182-
183-
wrapper.innerHTML = `
184-
<${itemTag}>Item 0</${itemTag}>
185-
<${itemTag}>Item 1</${itemTag}>
186-
<${itemTag}>Item 2</${itemTag}>
187-
`;
188-
189-
list = wrapper.shadowRoot.querySelector(listTag);
190-
await oneEvent(list, 'items-changed');
191-
});
192-
193-
afterEach(() => {
194-
document.body.removeChild(wrapper);
195-
});
196-
197-
it('should set items based on the children count', () => {
198-
expect(list.items.length).to.be.equal(3);
199-
});
200-
201-
it('should move focus to the next element on ArrowRight', async () => {
202-
list.orientation = 'horizontal';
203-
await nextUpdate(list);
204-
list.focus();
205-
arrowRight(list);
206-
expect(list.items[1].focused).to.be.true;
207-
});
208-
});
209-
210168
describe('selection', () => {
211169
beforeEach(async () => {
212170
list = fixtureSync(`
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { expect } from '@vaadin/chai-plugins';
2+
import { fixtureSync, nextRender } from '@vaadin/testing-helpers';
3+
import '@vaadin/menu-bar';
4+
import '@vaadin/tabs';
5+
6+
describe('tabs with menu-bar', () => {
7+
let tabs;
8+
9+
beforeEach(async () => {
10+
tabs = fixtureSync(`
11+
<vaadin-tabs>
12+
<vaadin-tab>
13+
<span>Tab 1</span>
14+
</vaadin-tab>
15+
</vaadin-tabs>
16+
`);
17+
await nextRender();
18+
});
19+
20+
it('should not include menu-bar items in tabs items', async () => {
21+
const menu = document.createElement('vaadin-menu-bar');
22+
const item = document.createElement('vaadin-menu-bar-item');
23+
item.textContent = 'Menu item';
24+
menu.items = [{ component: item }];
25+
26+
const tab = document.createElement('vaadin-tab');
27+
tab.textContent = 'Tab 2';
28+
tab.appendChild(menu);
29+
tabs.appendChild(tab);
30+
await nextRender();
31+
32+
expect(tabs.items.length).to.equal(2);
33+
expect(tabs.items.includes(item)).to.be.false;
34+
});
35+
});

0 commit comments

Comments
 (0)