Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly align overlay in RTL mode #584

Merged
merged 2 commits into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

script:
- if [[ "$POLYMER" = "2" ]]; then
npm -q i && npm i -q --no-save -g bower polymer-cli && bower -q i &&
npm -q i && npm i -q --no-save bower polymer-cli && bower -q i &&
gulp lint version:check &&
polymer lint --rules polymer-2 --input ./src/*.html ./theme/**/*.html &&
if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" && "$TRAVIS_BRANCH" != quick/* ]]; then
Expand Down
3 changes: 3 additions & 0 deletions src/vaadin-date-picker-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,9 @@
}
}

this.$.overlay.setAttribute('dir',
getComputedStyle(this._inputElement).getPropertyValue('direction')
);
this._overlayContent._repositionYearScroller();
}

Expand Down
4 changes: 4 additions & 0 deletions src/vaadin-date-picker-styles.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
align-items: flex-end;
}

:host([right-aligned][dir="rtl"]) {
align-items: flex-start;
}

[part="overlay"] {
display: flex;
flex: auto;
Expand Down
16 changes: 16 additions & 0 deletions test/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,22 @@
expect(window.getComputedStyle(flexDatePicker).width).to.eql('500px');
});
});

describe('Right-to-left', () => {
before(() => {
document.querySelector('body').setAttribute('dir', 'rtl');
});

after(() => {
document.querySelector('body').removeAttribute('dir');
});

it('overlay should position correctly', () => {
datepicker.open();
expect((overlayContent.getBoundingClientRect().right >= datepicker.getBoundingClientRect().right))
.to.be.true;
});
});
});

describe('Basic features theme attribute', () => {
Expand Down