TheComputerM / svelte-materialify

A Material UI Design Component library for Svelte heavily inspired by vuetify.

Home Page:https://svelte-materialify.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Textarea Label issue

GrochowskiC opened this issue · comments

class active is not applied on label because the labelActive variable is not reactive.
should have : $: labelActive = !!placeholder || value;
instead of : let labelActive = !!placeholder || value;

It's supposed to be updated through these methods no?

function onFocus() {
labelActive = true;
}
function onBlur() {
if (!value && !placeholder) labelActive = false;
if (validateOnBlur) checkRules();
}
function clear() {
value = '';
if (!placeholder) labelActive = false;
}

No. If the value is updated after initialization, by async data for example, labelActive will stay to false.
And to be consistent with the TextField component, you should use $:
(Also, to be consistent with TextField, use export validate() instead of checkRules and return error !)

Ah, true, I see what you mean now

Example REPL : https://svelte.dev/repl/1154fe4b3434494b88c2e1cf35960c76?version=3.38.1

(notice how the label doesn't shift up as the "test" string value gets updated)