Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Form] Make sure errors are a part of the label on bootstrap 4 - this is a requirement for WCAG2 #24435

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

Merged
merged 1 commit into from
Feb 4, 2018

Conversation

Nyholm
Copy link
Member

@Nyholm Nyholm commented Oct 5, 2017

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR symfony/symfony-docs#...

I recently let Europe's leading accessibility experts (Funkanu.se) review a site of mine, they gave me (among other) the feedback that errors should be a part of the label.

They said that it makes no sense for blind users to read label, read input and then read errors.

I know the implementation might look strange. But I wish something like this would be merged. That would be great for accessibility for all apps using Symfony.

We could also make sure it prints something like:

<label for=”name”>Name: <span class=”hidden”>Error message</span></label>
<input id=”name” type=”text”>
<span aria-hidden=”true”>Error message</span>

@fabpot
Copy link
Member

fabpot commented Oct 5, 2017

Is it really something that we could only implement for Bootstrap 4? Wouldn't it make sense to make the change to the other themes? Also, for Bootstrap 4, it should be done on 3.4, not master.

@ostrolucky
Copy link
Contributor

Wouldn't changing this in older themes be BC break?
Bootstrap 4 theme has been added in Symfony 3.4 so it's ok to do this there.

@fabpot
Copy link
Member

fabpot commented Oct 8, 2017

@ostrolucky I know that, but it's kind of weird to fix a real issue only for one theme.

@nicolas-grekas nicolas-grekas changed the base branch from master to 3.4 October 8, 2017 16:47
@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Oct 8, 2017
@nicolas-grekas
Copy link
Member

@Nyholm rebase on 3.4 needed (I already retargeted on github)

@nicolas-grekas
Copy link
Member

@Nyholm I just rebased on 3.4. Can you please review other comments?

@Nyholm
Copy link
Member Author

Nyholm commented Oct 12, 2017 via email

@Nyholm
Copy link
Member Author

Nyholm commented Oct 13, 2017

I've updated all the themes.
Please note that the design (depending on CSS) might break with these fixes.

If we are happy with the implementation I'll try to write a paragraph or two in the docs about this and how to remove the error from the label.

@xabbuh
Copy link
Member

xabbuh commented Oct 13, 2017

tests seem to need an update too

@Nyholm
Copy link
Member Author

Nyholm commented Oct 17, 2017

I updated some tests. It passes locally. Travis is not all happy, did I do it correctly?

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Nov 12, 2017

@Nyholm could you rebase + check tests please?

@Nyholm
Copy link
Member Author

Nyholm commented Nov 26, 2017

I've rebased and fixed one test.. I cannot figure out how to fix AbstractTableLayoutTest::testNestedFormError. Where is the documentation of DomCrawler?

@@ -327,7 +331,7 @@ public function testNestedFormError()
$this->assertWidgetMatchesXpath($form->createView(), array(),
'/table
[
./tr/td/ul[./li[.="[trans]Error![/trans]"]]
./tr/td/label/ul[./li[.="[trans]Error![/trans]"]]
/following-sibling::table[@id="name_child"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is wrong. I cannot figure out how to make it right. It should match:

<table id="my&amp;id" class="my&amp;class">
<tr>
        <td><label class="required">[trans]Child[/trans]<ul><li>[trans]Error![/trans]</li></ul></label></td>
        <td><table id="name_child">
<tr>
        <td><label class="required">[trans]Grand child[/trans]</label></td>
        <td><table id="name_child_grandChild">
    </table></td>
    </tr>
    </table></td>
    </tr>
<tr style="display: none">
        <td colspan="2"><input type="hidden" id="name__token" name="name[_token]"></td>
    </tr>
    </table>

@xabbuh
Copy link
Member

xabbuh commented Nov 26, 2017

@Nyholm Tests for the TwigBridge are green now. But it looks like you need to update some PHP templates too (see the failing FrameworkBundle tests).

@Nyholm
Copy link
Member Author

Nyholm commented Nov 26, 2017

Tests are green except for low/high. Also, Fabbot is a false negative

@@ -125,8 +125,8 @@
{%- set element = 'legend' -%}
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-legend')|trim}) -%}
{%- else -%}
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%}
{%- endif -%}
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the indention is broken

@Tobion
Copy link
Contributor

Tobion commented Nov 30, 2017

Don't merge such a bc break in a minor version

@nicolas-grekas
Copy link
Member

@Nyholm how could we move forward here?

@ostrolucky
Copy link
Contributor

I think this is still ok to go into bootstrap 4 theme, since that one needs to be changed in BC breaking way anyway to support newer bootstrap 4 release

@nicolas-grekas
Copy link
Member

@Nyholm because we cannot break BC, except on bootstrap 4 because it was not even stable before, what about focusing this PR only on bootstrap 4? That'd be a nice step. Would you have some time to make it before next release? (ie this week would be great)

@Nyholm
Copy link
Member Author

Nyholm commented Jan 22, 2018

Hey. Sorry for the delay. I will make sure to only change the bootstrap theme this week.

@Nyholm Nyholm force-pushed the form-wcag-error branch 2 times, most recently from 82ee2da to 3eb9e41 Compare January 28, 2018 15:33
@Nyholm
Copy link
Member Author

Nyholm commented Jan 28, 2018

There we go. The PR does only edit bootstrap 4 and added some tests to make sure it works.

I've also rebased on branch 3.4. But I guess it should be changed to master, right?

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jan 28, 2018

This should really go to 3.4 as bug fix. Later would mean BC breaks. Doing now is also a BC break, but matches the fact that BS4 just when out of beta.

@Nyholm
Copy link
Member Author

Nyholm commented Jan 28, 2018

Great great great. Then Im done with this PR. Im ready for a review.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(with minor nitpicking comments)

{%- if with_invert %}{{ form_widget(form.invert) }}{% endif -%}
</div>
{%- endif -%}
{%- endblock dateinterval_widget -%}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the last dash could be removed, just to remove an unneeded change in the patch

{%- set element = 'legend' -%}
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-legend')|trim}) -%}
{%- else -%}
{%- set label_attr = label_attr|merge({'for': id, class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for quotes around key (same below)

@Nyholm
Copy link
Member Author

Nyholm commented Jan 29, 2018

Thank you

@nicolas-grekas nicolas-grekas changed the title [Form] Make sure errors is a part of the label. This is a requirement for WCAG2 [Form] Make sure errors are a part of the label on bootstrap 4 - this is a requirement for WCAG2 Feb 4, 2018
@nicolas-grekas
Copy link
Member

Thank you @Nyholm.

@nicolas-grekas nicolas-grekas merged commit a0b40f5 into symfony:3.4 Feb 4, 2018
nicolas-grekas added a commit that referenced this pull request Feb 4, 2018
…ap 4 - this is a requirement for WCAG2 (Nyholm)

This PR was merged into the 3.4 branch.

Discussion
----------

[Form] Make sure errors are a part of the label on bootstrap 4 - this is a requirement for WCAG2

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!--highly recommended for new features-->

I recently let Europe's leading accessibility experts (Funkanu.se) review a site of mine, they gave me (among other) the feedback that errors should be a part of the label.

They said that it makes no sense for blind users to read label, read input and then read errors.

I know the implementation might look strange. But I wish something like this would be merged. That would be great for accessibility for all apps using Symfony.

We *could* also make sure it prints something like:

```
<label for=”name”>Name: <span class=”hidden”>Error message</span></label>
<input id=”name” type=”text”>
<span aria-hidden=”true”>Error message</span>
```

Commits
-------

a0b40f5 [Form] Make sure errors are a part of the label on bootstrap 4 - this is a requirement for WCAG2
@Nyholm Nyholm deleted the form-wcag-error branch February 4, 2018 15:34
@Nyholm
Copy link
Member Author

Nyholm commented Feb 4, 2018

Thank you for merging.

nicolas-grekas added a commit that referenced this pull request Feb 15, 2018
…le (mpiot, Nyholm)

This PR was merged into the 3.4 branch.

Discussion
----------

[TwigBridge] Apply some changes to support Bootstrap4-stable

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #25655 #25635 #24435
| License       | MIT
| Doc PR        | -

Follow up of #25715, see discussion there.

This fixes the following errors:
- Delete form-control-label, don't used in Bootstrap 4
- Replace col-form-legend by col-form-label
- Separate the label and input (before the input was in the label)
- Use form-check-inline to put radio and/or checkboxes inline
- Add support of custom form for radio and checkboxes
- Fix input-group: MoneyType (Issue #25655), PercentType
- Remove form-control duplication (Issue #25635)
- Fix Errors in label (#24435)

Commits
-------

14e2282 Fixed broken tests
cf4e956 [TwigBridge] Apply some changes to support Bootstrap4-stable
This was referenced Mar 1, 2018
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.

8 participants