-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Floating labels don't work inside input groups (prepend/append) #642
Comments
@UweKubosch @thimo This is a really interesting find. It makes me think that we've put the |
|
I wonder about changing the HTML. As I read it, we need to move the At the very least I realized we should document more clearly that we reserve the right to change the HTML when we realize that we've made a mistake in interpreting how we're supposed to use Bootstrap. |
Ah yes, didn't consider possibly breaking existing apps. Can we include this as a "breaking change" in the next minor release, probably 5.2? Then document why and what the impact is. I would think we at most would break a bit of CSS, but that's a dangerous assumption. Still I think we should fix this. |
Yes, I agree that's it's actually "broken" and needs to be fixed. I guess that's the nature of CSS that when we fix something, someone might have written some CSS that won't work after our fix. But so be it. Thanks for your input! |
Hello, Is it going to be changed accordigly to support input groups inside floating labels ? Thanks |
Yes, @shivam091 it's being worked on. It requires some non-trivial changes to the way the code is organized internally. If you would like to try putting together a PR to fix this, let us know. Otherwise, we appreciate your patience. |
I have tried it in my way by cloning the gem. Let's take example for password_field def form_group(*args, &block)
options = args.extract_options!
attribute_name = args.first
form_group_classes = form_group_classes(options)
label = generate_label(options[:id], attribute_name, options[:label], options[:label_col], options[:layout], options[:floating])
help_text = generate_help(attribute_name, options[:help_text])
options[:class] = form_group_classes if form_group_classes.present?
if group_layout_horizontal?(options[:layout])
prepend_and_append_input(attribute_name, options) do
concat(label) << tag.div(capture(&block) + help_text, class: form_group_control_class(options))
end
elsif options[:floating]
tag.dl(**form_group_attrs(options)) do
concat(prepend_and_append_input(attribute_name, options) do
concat(tag.div(class: "form-floating") do
concat(capture(&block))
concat(label)
end)
end)
concat(help_text)
end
else
tag.dl(**form_group_attrs(options)) do
concat(label)
concat(prepend_and_append_input(attribute_name, options) do
capture(&block)
end)
concat(help_text)
end
end
end def password_field(attribute_name, options = {})
label_options = options.fetch(:label, {})
form_group_builder(attribute_name, options) do
options[:placeholder] ||= label_text(attribute_name, label_options) if options.delete(:floating)
super(attribute_name, options)
end
end
Removed unused |
The above are major tweaks I have added in for getting the output but it might have some other breaks which I need to check and fix @lcreid |
Thanks for this. You're in the right area all right. If you'd like to submit a pull request, I can review it. Check out our Contributing document. I have made some progress but I won't be able to finish anything before the weekend. |
Yes I will try. I am not having idea on writing test cases therfore I may also require some amount of time. I try my best to submit the PR. Thank you |
Thanks for giving this a go, @shivam091 If you're struggling to get all the tests working, I have something that I think is working. The existing code didn't make this change easy. If you want to continue with the PR, I suggest that you create a draft with just the tests, so we can agree on what the new HTML should look like. |
Yes @lcreid, I check it and try to submit tests asap. |
<div class="input-group">
<span class="input-group-text">@</span>
<div class="form-floating ">
<input class="form-control" placeholder="Password" type="password" name="user[password]" id="user_password">
<label class="required" for="user_password">Password</label>
</div>
<span class="input-group-text">@</span>
</div> This markup is generated with my changes which I thing perfext according to Bootstrap 5.2 upgrades. NOTE - I considered upgrading bootstrap to 5.2 because styles required for input groups and floating labels for a element was missing in 5.0 5.1 versions. |
I think that HTML will work. However, be sure to try it with the This JSFiddle shows the difference between the OP's solution and yours: https://jsfiddle.net/qhem392r/4/. Nice find about the versions. We'll may have to change the installation instructions so people use the right version of Bootstrap. |
I am taking a look at this issue now. |
Floating labels don't display correctly if they're used with an input group, i.e. if
prepend:
orappend:
are set.Generates:
To work, I think there should only be one wrapper element, and the label should be placed alongside the input, i.e.:
The text was updated successfully, but these errors were encountered: