Skip to content
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

Help text rendered inside input-group instead of form-group #444

Closed
ehutzelman opened this issue Feb 28, 2018 · 7 comments
Closed

Help text rendered inside input-group instead of form-group #444

ehutzelman opened this issue Feb 28, 2018 · 7 comments

Comments

@ehutzelman
Copy link
Contributor

I believe this may be related to #434

When using help text along with a prepend, the following structure is generated with the help text being rendered inside the input-group:

<div class="form-group">
  <label>Label</label>
  <div class="input-group">
    <div class="input-group-prepend">
      <span class="input-group-text">$</span>
    </div>
    <input class="form-control" type="text" name="my_field">
    <small class="form-text text-muted">help text here...</small> <!-- Original location -->
  </div>
</div>

This is causing rending issues at some widths with the help text being rendered to the right of the input field instead of below it. When moving the help text outside of the input-group and inside the outer form-group, the issue seems to be fixed and the help text renders underneath the input field as expected:

<div class="form-group">
  <label>Label</label>
  <div class="input-group">
    <div class="input-group-prepend">
      <span class="input-group-text">$</span>
    </div>
    <input class="form-control" type="text" name="my_field">
  </div>
  <small class="form-text text-muted">help text here...</small>  <!-- Moved here -->
</div>
@lcreid
Copy link
Contributor

lcreid commented Feb 28, 2018

Thanks for taking the time to report this. This is is a great bug report.

In v2.7 of bootstrap_form, aka the Bootstrap 3 version, the help text was not rendered if there was a validation error. No one currently active on bootstrap_form knows why for sure, although #284 (comment) gives a plausible explanation.

Whatever the reason, the code for help and error messages is basically in one method. We've been trying to minimize code changes as much as practical for the Bootstrap 4 version, so we rendered help and errors inside .input-group with the same method. This means they come out in the same place. #417 noted that the validation errors need to be inside the .input-group. Your report confirms that the help text has to be outside the .input-group. So something has to change. :-)

@ehutzelman would you like to take a shot at a PR for the .input-group case? If so, please comment here and/or assign the issue to yourself. If not, no worries. We like to encourage the community to contribute, but if you can't, we'll fix this sooner rather than later.

@ehutzelman
Copy link
Contributor Author

Thanks for the quick response @lcreid. I've overbooked myself for March, but I could possibly pick this up in April if it remains unresolved. If anyone gets to it before then, more power to them :)

@lcreid
Copy link
Contributor

lcreid commented Mar 1, 2018

No worries, @ehutzelman . @parkeryoung, if you're still looking to contribute, this might be a good bug to fix. Comment here or assign yourself near the top-right of this page so we know you're working on it.

@parkeryoung
Copy link
Contributor

parkeryoung commented Mar 1, 2018

@lcreid I'll take a look at it.

Edit - I don't believe I can assign myself either.

parkeryoung added a commit to parkeryoung/bootstrap_form that referenced this issue Mar 2, 2018
The help text and error message are no longer rendered in the same
place. The help text is now rendered in the `form-group` div instead
of in the `input-group` div. Before we could render the error and help
text together, however that has changed and they need to be separate.

With this separation we need to check in the `generate_help` method to
see if there are errors and if inline errors are being rendered; as we
don't want to render the help text then.
parkeryoung added a commit to parkeryoung/bootstrap_form that referenced this issue Mar 2, 2018
The help text and error message are no longer rendered in the same
place. The help text is now rendered in the `form-group` div instead
of in the `input-group` div. Before we could render the error and help
text together, however that has changed and they need to be separate.

With this separation we need to check in the `generate_help` method to
see if there are errors and if inline errors are being rendered; as we
don't want to render the help text then.
@parkeryoung
Copy link
Contributor

There is a fix for this here, hope it suffices.

mattbrictson added a commit that referenced this issue Mar 2, 2018
…-group

Issue #444 - Help text rendered in wrong place.
@mattbrictson
Copy link
Contributor

Fixed via #445

@ehutzelman
Copy link
Contributor Author

Thanks for the quick fix on this one @parkeryoung, much appreciated.

lcreid pushed a commit to lcreid/rails-bootstrap-forms that referenced this issue Jun 4, 2018
The help text and error message are no longer rendered in the same
place. The help text is now rendered in the `form-group` div instead
of in the `input-group` div. Before we could render the error and help
text together, however that has changed and they need to be separate.

With this separation we need to check in the `generate_help` method to
see if there are errors and if inline errors are being rendered; as we
don't want to render the help text then.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants