Reputation: 2771
The autofocus attribute doesn't trigger the Bootstrap-JavaScript to add the is-focused
class to the corresponding (bmd-)form-group
.
<fieldset class="form-group bmd-form-group">
<label for="usernameControl" class="bmd-label-floating">Username</label>
<input type="text" class="form-control text-light" required="" id="usernameControl" name="username" autofocus="">
</fieldset>
When typing something in the field, the label goes up because is-filled
gets added, but the focus is still not recognized.
<fieldset class="form-group bmd-form-group is-filled">
<label for="usernameControl" class="bmd-label-floating">Username</label>
<input type="text" class="form-control text-light" required="" id="usernameControl" name="username" autofocus="">
</fieldset>
Deselecting the text-input (with mouseclicks or the tab-key) and then selecting it again is the only way to get the is-focused
class (and therefore making it look like it should).
<fieldset class="form-group bmd-form-group is-filled is-focused">
<label for="usernameControl" class="bmd-label-floating">Username</label>
<input type="text" class="form-control text-light" required="" id="usernameControl" name="username" autofocus="">
</fieldset>
Is there any fix or workaround to this problem?
Bootstrap Material Design used: https://fezvrasta.github.io/bootstrap-material-design/ (Version 4.1.1)
<fieldset class="form-group">
<label for="usernameControl" class="bmd-label-floating">Username</label>
<input type="text" class="form-control text-light" required="" id="usernameControl" name="username" autofocus="">
</fieldset>
Upvotes: 0
Views: 5295
Reputation: 11
<script> $('body').bootstrapMaterialDesign({}); </script>
add this to your website if you're using https://fezvrasta.github.io/bootstrap-material-design This will fix forms etc.
Upvotes: 1
Reputation: 359
If you guys are using like below code it's fine (bmd-)form-group.
<input type="text" class="form-control text-light" id="usernameControl" name="username">
If you are using property like autofocus,required,readonly ect.. i:
autofocus, required, readonly and alike, it wouldn't work, so you have to add a new custom class to work this scenario.
Upvotes: 0
Reputation: 2771
My solution: Hardcoding the is-focused
class to the corresponding (bmd-)form-group
of the autofocused item works.
<fieldset class="form-group is-focused">
<label for="usernameControl" class="bmd-label-floating">Username</label>
<input type="text" class="form-control text-light" required="" id="usernameControl" name="username" autofocus="">
</fieldset>
Upvotes: 1