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

WIP Initial naive form validation fix #28995

Closed
wants to merge 1 commit into from

Conversation

patrickhlauke
Copy link
Member

A first attempt at mocking up the actual JavaScript behavior for correct custom form validation handling

Not mergeable yet, just pushing this as a proof of concept. This should really be rolled into a proper plugin/JavaScript behavior.

x-ref #28414

@patrickhlauke
Copy link
Member Author

@mdo i remembered you discussed potential use of data attributes for this ... here's the first naive stab at it. apart from the general ugliness of the code, one aspect that's still not ideal is that the feedback does show dynamically based on validity of the form control, meaning that the problem will still happen that if there was an initial feedback which is then tied to the control, if the validity changes dynamically (after the first submit), the feedback may be hidden, but it's still associated via aria-describedby and announced by AT. or it wants to show another feedback now, but it can't because the JS doesn't kick in. we likely need to also hook into the change event of each form control to trigger the whole processing dynamically (to keep up with the CSS that is evaluated dynamically)...

@patrickhlauke
Copy link
Member Author

for this proof of concept, only fiddled with that first form at https://deploy-preview-28995--twbs-bootstrap.netlify.com/docs/4.3/components/forms/#custom-styles

@MartijnCuppens
Copy link
Member

I like the idea. I would also provide an example with as well the data-validation-valid as data-validation-invalid attributes.

@Johann-S
Copy link
Member

Like I said in Slack, I think it's a good idea but for me, it lacks of features, just accessibility, and a simple validation isn't enough for a core components

@patrickhlauke
Copy link
Member Author

@Johann-S well, put it this way: the current use of just CSS to show/hide validation messages is not accessible. we either fix that in our core (and if it requires JS, add it as a plugin, as we can't expect authors to copy/paste an enormous chunk of code just to make things run correctly when they use it), or we ditch the validation messages altogether.

@patrickhlauke
Copy link
Member Author

For me, the fact the validation errors aren't actually conveyed properly is a blocker. Annoyed I've not caught that sooner in v4, but...it is what it is.

@mdo mdo changed the base branch from master to main June 16, 2020 20:18
@patrickhlauke patrickhlauke marked this pull request as draft June 27, 2020 10:13
@mdo
Copy link
Member

mdo commented Sep 16, 2020

Given #31666 and #31677, thinking we can isolate the JS changes here in another PR?

@XhmikosR
Copy link
Member

Does this still apply to v5?

@patrickhlauke
Copy link
Member Author

Does this still apply to v5?

yes, https://v5.getbootstrap.com/docs/5.0/forms/validation/ still has issues - custom styles and tooltips examples, the errors are not associated with the form controls and not announced by AT. also, in the support elements example, the errors are likewise not associated. for custom and tooltip, this needs javascript to dynamically inject the error, OR to dynamically add/remove the aria-describedby (as if it's there from the start, even when it's set to display:none, AT will announce the error otherwise)

@XhmikosR XhmikosR added this to Inbox in v5.0.0-beta2 via automation Nov 25, 2020
@XhmikosR XhmikosR added this to Inbox in v5.0.0-beta3 via automation Dec 14, 2020
@XhmikosR XhmikosR removed this from Inbox in v5.0.0-beta2 Dec 14, 2020
@mdo
Copy link
Member

mdo commented Feb 11, 2021

This one is pretty out of date, is it still relevant?

@patrickhlauke
Copy link
Member Author

the original problem still persists, but this got scuppered by my lack of JS chops / how to make the scripting etc apply automagically.

@XhmikosR
Copy link
Member

@patrickhlauke can you explain a bit more in detail what you are missing? Maybe @GeoSot could help us out here.

@patrickhlauke
Copy link
Member Author

@patrickhlauke can you explain a bit more in detail what you are missing? Maybe @GeoSot could help us out here.

what's really missing is some kind of clean way to actually make this part of Bootstrap's JS. how to generalise this somehow to make it easily usable, automatically adding/removing the aria-describedby ... ideally, somebody who's familiar with BS' slightly over-complicated JS way of doing things. maybe @rohit2sharma95 can have a look as well?

@patrickhlauke
Copy link
Member Author

Superseded by #34043

@patrickhlauke patrickhlauke deleted the patrickhlauke-form-validation branch July 14, 2022 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants