floating-form-labels
floating-form-labels copied to clipboard
Proposal: If "floatedClass" is already present, do nothing
Currently, if you manually set the floatedClass
on a Wrapper-Element, floating-form-labels gets initialized and resets the floatedClass
.
In my opinion this should behave like so:
If the plugin sees that there is already a floatedClass
, it should only set the events but don't float the label.
This comes in handy if you manually want to initially float a label to workaround #12 for example.
In the project I'm currently working on, we achieve this behavior by making the following
$('.ffl-wrapper:not(".ffl-floated")').floatingFormLabels();
But I think this should be handled by the plugin itself.
@Baedda @jChris85 What do you think?
I don't know if this should be a plugin feature.
If you want to have support for users with disabled JS for example, you need to set the floatedClass
to all wrapper elements initially. The plugin should remove the class, when JS is enabled / loaded.
@Baedda what do you think?
Maybe we should switch the logic completely? Would you think it is better that by default the labels are floated and when JS kicks in they get positioned above the input? This would help in the use case of @Miw0 and would be better for people without JavaScript as @apriljunge mentioned.
But for the default use case people could see the labels moving. That was what I tried to avoid as I wrote the plugin. I wonder what would be the best way.
I just stumbled on this issue when working with this great plugin.
I think I have a use case in which people do see the label moving. My input has an autofocus attribute. I tried to add the class ffl-floated to the wrapper div, but it still moves on page load.
Using @Miw0's solution to not initialize the plugin for labels for which the wrapper already floats solves it, but naturally, when the input loses focus, the label does not float into the input anymore.
@pimhooghiemstra thank you for this input! Autofocus is a think we totally forgot to think about. I will try to cover this for the next release.
@Baedda perfect. In the meantime I'll just have a moving label when the input is autofocussed, not a big problem in this case. Thanks for the quick reply!