|
6 | 6 |
|
7 | 7 | <link rel="import" href="../paper-input/paper-input.html">
|
8 | 8 | <link rel="import" href="../paper-dropdown-menu/paper-dropdown-menu.html">
|
| 9 | +<link rel="import" href="../neon-animation/web-animations.html"> |
9 | 10 |
|
10 | 11 | <link rel="import" href="../cosmoz-i18next/cosmoz-i18next.html">
|
11 | 12 |
|
|
29 | 30 | horizontal-align="[[ preferredDropdownHorizontalAlign ]]" opened="{{ headerFocused }}">
|
30 | 31 | <div class="dropdown-content" slot="dropdown-content" style="padding: 15px; min-width: 100px;">
|
31 | 32 | <h3 style="margin: 0;">[[ title ]]</h3>
|
32 |
| - <paper-input type="number" label="[[ _('From', t) ]]" value="{{ _filterInput.min }}" |
| 33 | + <paper-input type="number" label="[[ _('From', t) ]]" value="{{ _filterInput.min }}" on-input="onBadInputFloatLabel" |
33 | 34 | min="[[ _toInputString(_limit.fromMin) ]]" max="[[ _toInputString(_limit.fromMax) ]]">
|
34 | 35 | </paper-input>
|
35 |
| - <paper-input type="number" label="[[ _('To', t) ]]" value="{{ _filterInput.max }}" |
| 36 | + <paper-input type="number" label="[[ _('To', t) ]]" value="{{ _filterInput.max }}" on-input="onBadInputFloatLabel" |
36 | 37 | min="[[ _toInputString(_limit.toMin) ]]" max="[[ _toInputString(_limit.toMax) ]]">
|
37 | 38 | </paper-input>
|
38 | 39 | </div>
|
@@ -105,6 +106,26 @@ <h3 style="margin: 0;">[[ title ]]</h3>
|
105 | 106 | return new Intl.NumberFormat(locale || undefined, options);
|
106 | 107 | }
|
107 | 108 |
|
| 109 | + /** |
| 110 | + * Check if label should float based on validity |
| 111 | + * |
| 112 | + * Number inputs can have allowed characters that aren't numbers (-,e) and won't |
| 113 | + * trigger a value change and thus not float the label. |
| 114 | + * However, the validity will report badInput so we can trigger a label float by |
| 115 | + * setting it to something truthy but still not visible. |
| 116 | + * Fixed in paper-input 3.x |
| 117 | + * |
| 118 | + * @param {Event} event KeyboardEvent |
| 119 | + * @returns {void} |
| 120 | + */ |
| 121 | + onBadInputFloatLabel(event) { |
| 122 | + const paperInput = event.currentTarget; |
| 123 | + if (paperInput == null || paperInput.tagName !== 'PAPER-INPUT') { |
| 124 | + return; |
| 125 | + } |
| 126 | + paperInput.placeholder = paperInput.$.nativeInput.validity.badInput ? ' ' : ''; |
| 127 | + } |
| 128 | + |
108 | 129 | /**
|
109 | 130 | * Get the comparable value of an item.
|
110 | 131 | *
|
|
0 commit comments