Skip to content

Commit

Permalink
fix: explicitly set relative positioning on scroll containers (#5714) (
Browse files Browse the repository at this point in the history
  • Loading branch information
bwajtr committed Mar 28, 2023
1 parent e4d0f83 commit dfc9800
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/combo-box/src/vaadin-combo-box-scroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class ComboBoxScroller extends PolymerElement {
border-width: var(--_vaadin-combo-box-items-container-border-width);
border-style: var(--_vaadin-combo-box-items-container-border-style);
border-color: var(--_vaadin-combo-box-items-container-border-color);
position: relative;
}
</style>
<div id="selector">
Expand Down
41 changes: 39 additions & 2 deletions packages/combo-box/test/lit.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect } from '@esm-bundle/chai';
import { fixtureSync } from '@vaadin/testing-helpers';
import { fixtureSync, nextFrame } from '@vaadin/testing-helpers';
import './not-animated-styles.js';
import '../vaadin-combo-box.js';
import { html, render } from 'lit';
import { html, LitElement, render } from 'lit';
import { getViewportItems } from './helpers.js';

describe('lit', () => {
Expand Down Expand Up @@ -36,4 +36,41 @@ describe('lit', () => {
expect(getViewportItems(comboBox)[0].textContent).to.equal('new-0');
});
});

describe('complex structure', () => {
let container, comboBox, selector;

class TestSlotContainer extends LitElement {
render() {
return html`<slot></slot> `;
}
}
customElements.define('test-slot-container', TestSlotContainer);

class TestSlottedComboComponent extends LitElement {
render() {
return html`
<test-slot-container>
<vaadin-combo-box .items="${['First', 'Second', 'Third']}"></vaadin-combo-box>
</test-slot-container>
`;
}
}
customElements.define('test-slotted-combo-component', TestSlottedComboComponent);

beforeEach(async () => {
container = fixtureSync('<div></div>');
render(html`<test-slotted-combo-component></test-slotted-combo-component>`, container);
await nextFrame();
const component = container.querySelector('test-slotted-combo-component');
comboBox = component.shadowRoot.querySelector('vaadin-combo-box');
selector = comboBox._scroller.shadowRoot.children.selector;
});

it('should not show horizontal scrollbar when placed in slotted container', () => {
comboBox.open();

expect(getComputedStyle(selector).position).to.equal('relative');
});
});
});
4 changes: 4 additions & 0 deletions packages/virtual-list/src/vaadin-virtual-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class VirtualList extends ElementMixin(ControllerMixin(ThemableMixin(PolymerElem
:host(:not([grid])) #items > ::slotted(*) {
width: 100%;
}
#items {
position: relative;
}
</style>
<div id="items">
Expand Down

0 comments on commit dfc9800

Please sign in to comment.