|
66 | 66 | {#if !noLabel && (label != null || $$slots.label)}
|
67 | 67 | <FloatingLabel
|
68 | 68 | bind:this={floatingLabel}
|
69 |
| - floatAbove={value != null && value !== ''} |
| 69 | + floatAbove={focused || (value != null && value !== '')} |
70 | 70 | {required}
|
71 | 71 | wrapped
|
72 | 72 | {...prefixFilter($$restProps, 'label$')}
|
|
83 | 83 | {#if !noLabel && (label != null || $$slots.label)}
|
84 | 84 | <FloatingLabel
|
85 | 85 | bind:this={floatingLabel}
|
86 |
| - floatAbove={value != null && value !== ''} |
| 86 | + floatAbove={focused || (value != null && value !== '')} |
87 | 87 | {required}
|
88 | 88 | wrapped
|
89 | 89 | {...prefixFilter($$restProps, 'label$')}
|
|
111 | 111 | bind:dirty
|
112 | 112 | bind:invalid
|
113 | 113 | {updateInvalid}
|
| 114 | + on:blur={() => (focused = false)} |
| 115 | + on:focus={() => (focused = true)} |
114 | 116 | on:blur
|
115 | 117 | on:focus
|
116 | 118 | aria-controls={helperId}
|
|
134 | 136 | bind:dirty
|
135 | 137 | bind:invalid
|
136 | 138 | {updateInvalid}
|
| 139 | + on:blur={() => (focused = false)} |
| 140 | + on:focus={() => (focused = true)} |
137 | 141 | on:blur
|
138 | 142 | on:focus
|
139 | 143 | aria-controls={helperId}
|
|
290 | 294 | let internalClasses = {};
|
291 | 295 | let internalStyles = {};
|
292 | 296 | let helperId;
|
| 297 | + let focused = false; |
293 | 298 | let addLayoutListener = getContext('SMUI:addLayoutListener');
|
294 | 299 | let removeLayoutListener;
|
295 | 300 | let initPromiseResolve;
|
|
351 | 356 | .map((mutation) => mutation.attributeName)
|
352 | 357 | .filter((attributeName) => attributeName);
|
353 | 358 | };
|
354 |
| - const observer = new MutationObserver((mutationsList) => |
355 |
| - handler(getAttributesList(mutationsList)) |
356 |
| - ); |
| 359 | + const observer = new MutationObserver((mutationsList) => { |
| 360 | + if (useNativeValidation) { |
| 361 | + handler(getAttributesList(mutationsList)); |
| 362 | + } |
| 363 | + }); |
357 | 364 | const config = { attributes: true };
|
358 | 365 | observer.observe(input.getElement(), config);
|
359 | 366 | return observer;
|
|
0 commit comments