quasar icon indicating copy to clipboard operation
quasar copied to clipboard

Floating label doesn't work on input[type=email] when value is not valid

Open eliashdezr opened this issue 9 years ago • 10 comments

Using this code

<div class="floating-label">
  <input required="required" type="email" class="full-width">
<label>Email</label></div>

And typing anything without the @ causes this behavior on the label: 2016-12-06 23_12_46-asistente asesores

eliashdezr avatar Dec 07 '16 05:12 eliashdezr

Hmm that's kind of strange. from https://github.com/quasarframework/quasar/blob/dev/src/css-components/textfield/textfield.mat.styl and https://github.com/quasarframework/quasar/blob/dev/src/css-components/textfield/textfield.ios.styl there is not difference in the types of input tags to be seen. But maybe I'm looking at the wrong part of the code.

vuchl avatar Dec 07 '16 05:12 vuchl

New component coming soon for floating label.

rstoenescu avatar Dec 07 '16 07:12 rstoenescu

@rstoenescu Cool!

Btw, just wanted to add another strange behavior on the password input label: 2016-12-07 04_07_13-asistente asesores

Hope this helps in the new component!

eliashdezr avatar Dec 07 '16 10:12 eliashdezr

@eliashdezr Thanks, I'll make sure that's included in the fix (which I'm doing now)

CookieJon avatar Dec 10 '16 02:12 CookieJon

PR is being worked on by @CookieJon

rstoenescu avatar Dec 12 '16 08:12 rstoenescu

@CookieJon @rstoenescu Don't know if you found the solution, I guess the problem happens here:

https://github.com/quasarframework/quasar/blob/dev/src/css-components/textfield/textfield.mat.styl#L67 (input:valid)

I was investigating how MaterializeCss solve this, they put a .active class via jQuery into input when it doesn't have focus or when it have a value.

@eliashdezr as a workahound for now you could remove type="email" from input and validate it with vuelidate (it has an email validator out of the box)

oswaldofreitas avatar Feb 09 '17 19:02 oswaldofreitas

Consider this solved. There's a mega-patch coming up for form components.

rstoenescu avatar Feb 09 '17 20:02 rstoenescu

Do you have a planned date for this to be released?

Please, consider creating a q-input with properties like: label, label type (floating, stacked, left).

Would be nice to have integration with validation showing message (could have a rule property).

So, instead of:

<div class="floating-label">
  <input required class="full-width"
    v-model.trim="vm.email" @change="$v.vm.email.$touch()"
    :class="{'has-error': $v.vm.email.$error}">
  <label>E-mail</label>
</div>
<div v-if="$v.vm.email.$error" class="text-negative">
  <small v-if="!$v.vm.email.required">E-mail is mandatory</small>
  <small v-if="!$v.vm.email.email">Please, inform a valid e-mail</small>
</div>

We could have:

<q-input label="E-mail" label-type="floating" v-model.trim="vm.email" validation-rule="email"></q-input>

class="full-width" by default

validation object could be something like

email {
  required: { message: "E-mail is mandatory" },
  email: { message: "Please, inform a valid e-mail" }
}

oswaldofreitas avatar Feb 09 '17 21:02 oswaldofreitas

@oswaldomilet It's exactly what I've been working on the whole week :) + more other form related things.

rstoenescu avatar Feb 10 '17 20:02 rstoenescu

Will be available in v0.14

rstoenescu avatar Feb 24 '17 14:02 rstoenescu