Skip to content

Commit

Permalink
Fix: preserve ltr on input and overlay (#146)
Browse files Browse the repository at this point in the history
* fix: make input and overlay work from left-to-right in RTL

* Update screenshots
  • Loading branch information
yuriy-fix authored and alvarezguille committed May 27, 2020
1 parent 7768e5b commit 44a50ad
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 2 deletions.
26 changes: 26 additions & 0 deletions src/vaadin-time-picker-text-field.html
Expand Up @@ -6,6 +6,32 @@

<link rel="import" href="../../vaadin-text-field/src/vaadin-text-field.html">

<dom-module id="vaadin-time-picker-text-field-styles" theme-for="vaadin-time-picker-text-field">
<template>
<style>
:host([dir="rtl"]) [part="input-field"] {
direction: ltr;
}

:host([dir="rtl"]) [part="value"]::placeholder {
direction: rtl;
text-align: left;
}

:host([dir="rtl"]) [part="input-field"] ::slotted(input)::placeholder {
direction: rtl;
text-align: left;
}

:host([dir="rtl"]) [part="value"]:-ms-input-placeholder,
:host([dir="rtl"]) [part="input-field"] ::slotted(input):-ms-input-placeholder {
direction: rtl;
text-align: left;
}
</style>
</template>
</dom-module>

<script>
(function() {
/**
Expand Down
1 change: 1 addition & 0 deletions src/vaadin-time-picker.html
Expand Up @@ -39,6 +39,7 @@
disabled="[[disabled]]"
readonly="[[readonly]]"
auto-open-disabled="[[autoOpenDisabled]]"
dir="ltr"
theme$="[[theme]]">
<template>
[[item.label]]
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion test/visual/test.js
Expand Up @@ -18,7 +18,12 @@ gemini.suite('vaadin-time-picker', function(rootSuite) {
suite
.setUrl('default.html')
.setCaptureElements('#default-tests')
.capture('default');
.capture('default')
.capture('rtl', function(actions) {
actions.executeJS(function(window) {
window.document.dir = 'rtl';
});
});
});

gemini.suite('dropdown', function(suite) {
Expand All @@ -42,6 +47,13 @@ gemini.suite('vaadin-time-picker', function(rootSuite) {
window.closeTimePickers();
window.document.querySelector('#step').__dropdownElement.opened = true;
});
})
.capture('rtl', function(actions) {
actions.executeJS(function(window) {
window.closeTimePickers();
window.document.dir = 'rtl';
window.document.querySelector('#plain').__dropdownElement.opened = true;
});
});
});

Expand Down
1 change: 0 additions & 1 deletion theme/lumo/vaadin-time-picker-styles.html
@@ -1,5 +1,4 @@
<link rel="import" href="../../../vaadin-combo-box/theme/lumo/vaadin-combo-box-light.html">
<link rel="import" href="../../../vaadin-text-field/theme/lumo/vaadin-text-field.html">
<link rel="import" href="../../../vaadin-lumo-styles/mixins/field-button.html">
<link rel="import" href="../../../vaadin-lumo-styles/font-icons.html">

Expand Down
18 changes: 18 additions & 0 deletions theme/lumo/vaadin-time-picker-text-field-styles.html
@@ -0,0 +1,18 @@
<link rel="import" href="../../../vaadin-text-field/theme/lumo/vaadin-text-field.html">

<dom-module id="lumo-time-picker-text-field" theme-for="vaadin-time-picker-text-field">
<template>
<style>
:not(*):placeholder-shown, /* to prevent broken styles on IE */
:host([dir="rtl"]) [part="value"]:placeholder-shown,
:host([dir="rtl"]) [part="input-field"] ::slotted(input:placeholder-shown) {
--_lumo-text-field-overflow-mask-image: none;
}

:host([dir="rtl"]) [part="value"],
:host([dir="rtl"]) [part="input-field"] ::slotted(input) {
--_lumo-text-field-overflow-mask-image: linear-gradient(to left, transparent, #000 1.25em);
}
</style>
</template>
</dom-module>
1 change: 1 addition & 0 deletions theme/lumo/vaadin-time-picker.html
@@ -1,2 +1,3 @@
<link rel="import" href="vaadin-time-picker-styles.html">
<link rel="import" href="vaadin-time-picker-text-field-styles.html">
<link rel="import" href="../../src/vaadin-time-picker.html">

0 comments on commit 44a50ad

Please sign in to comment.