Skip to content

Commit 0ab8e31

Browse files
fix: do not include nested child nodes in tabs items (#10043) (#10121)
Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
1 parent 3f5c7c7 commit 0ab8e31

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
@@ -11,7 +11,6 @@ import {
1111
keyDownChar,
1212
nextRender,
1313
nextUpdate,
14-
oneEvent,
1514
} from '@vaadin/testing-helpers';
1615
import sinon from 'sinon';
1716
import { ListMixin } from '../src/list-mixin.js';
@@ -163,47 +162,6 @@ describe('ListMixin', () => {
163162
});
164163
});
165164

166-
describe('wrapped list with slotted items', () => {
167-
let wrapper;
168-
169-
beforeEach(async () => {
170-
wrapper = document.createElement('div');
171-
document.body.appendChild(wrapper);
172-
173-
const root = wrapper.attachShadow({ mode: 'open' });
174-
root.innerHTML = `
175-
<${listTag}>
176-
<slot></slot>
177-
</${listTag}>
178-
`;
179-
180-
wrapper.innerHTML = `
181-
<${itemTag}>Item 0</${itemTag}>
182-
<${itemTag}>Item 1</${itemTag}>
183-
<${itemTag}>Item 2</${itemTag}>
184-
`;
185-
186-
list = wrapper.shadowRoot.querySelector(listTag);
187-
await oneEvent(list, 'items-changed');
188-
});
189-
190-
afterEach(() => {
191-
document.body.removeChild(wrapper);
192-
});
193-
194-
it('should set items based on the children count', () => {
195-
expect(list.items.length).to.be.equal(3);
196-
});
197-
198-
it('should move focus to the next element on ArrowRight', async () => {
199-
list.orientation = 'horizontal';
200-
await nextUpdate(list);
201-
list.focus();
202-
arrowRight(list);
203-
expect(list.items[1].focused).to.be.true;
204-
});
205-
});
206-
207165
describe('selection', () => {
208166
beforeEach(async () => {
209167
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)