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

Remove wrapping <div> and its class has-error for widgets #448

Open
2 tasks
stevepiercy opened this issue Aug 22, 2020 · 3 comments
Open
2 tasks

Remove wrapping <div> and its class has-error for widgets #448

stevepiercy opened this issue Aug 22, 2020 · 3 comments
Labels
BS5 Bootstrap 4
Milestone

Comments

@stevepiercy
Copy link
Member

This issue requires two things.

  • Move the class is-invalid (formerly known as has-error) from the widget's wrapping <div> to the <input>'s class itself.
  • Delete the <div> wrapping the control.

See #431 (comment)

@trollfot
Copy link

trollfot commented Nov 22, 2023

The wrapping div, currently, allows us to group the label and the input/input-group, the feedback and the error in a logical container, named #item-${oid}. I don't think removing it would improve things.

@stevepiercy
Copy link
Member Author

stevepiercy commented Nov 22, 2023

@trollfot let's use the examples in my comment about the current and proposed markup for discussion.

Taking the "Example of server-side validation error style with description" and modifying it, would this be preferable, where the differences from the original example would be:

  • preserve the wrapping div
  • remove the has-error class
  • setting the div's id to align with the input's id
<div
    class="form-group item-text"
    title="Enter some text"
    id="item-inputPassword">
<label for="inputPassword">Password</label>
<input type="text" class="form-control is-invalid" id="inputPassword" aria-describedby="inputPasswordFeedback" required>
<div id="inputPasswordFeedback" class="invalid-feedback">
You entered only 7 characters, but at least 8 are required.
</div>
<small id="passwordHelpBlock" class="form-text text-danger">
  Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji.
</small>
</div>

@trollfot
Copy link

As a note : there are some exceptions. For the complex widgets, some wrapping divs still need to hold the error marker (is-invalid). Without this, the invalid-feedback block does not show up (it's hidden by CSS). The BS5 CSS enforces that the parent or direct sibling should have the class in order to display the error fully. it's true with nested structures, like the checked input/password and the date parts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BS5 Bootstrap 4
Projects
None yet
Development

No branches or pull requests

2 participants