Problem/Motivation

When exposing a views filter on a numeric or date field the labels shown are missing or not placed in a logical order. Also there is no containing span to group operator and input field(s). This is related to / extends #2480719: Missing label and description for exposed numeric filter when using 'between' filter

Filter that has no exposed operator:

Filter that has an exposed operator with a single input value:

The label and description are not rendered correctly. There is no span surrounding the two elements for styling / keeping them together. The operator filter element label "Operator" is rendered in the same style as a separate filter.

Filter that has an exposed operator with multiple input values:

The label and description are rendered on the first of the two inputs. There is no span surrounding the three elements for styling / keeping them together. The operator filter element label "Operator" and the "And" label are rendered in the same style as a separate filter. This is the behaviour after applying the patch for #2480719: Missing label and description for exposed numeric filter when using 'between' filter. The Language filter is shown for reference how the exposed filter looks when showing a row of filters.

Key UI/UX/Accessibility bugs fixed by this issue

  1. Site builders can define a label for a filter in the Views UI, but the label doesn't appear at all in these cases, neither visually, nor for screen readers.
  2. Operator and related form elements are not grouped in any way, neither visually, nor for assistive tech. There's no way to tell which form elements a given operator choice is impacting.
  3. Is (not)? between filters have no meaningful label for min vs. max. "And" is a bizarre and unhelpful label. The filter label needs to apply to the whole set of elements, not just the "min" value.

Proposed resolution

Do what was done in D7 Views.

Single

Single operator exposed

Multiple

Multiple operator exposed

Remaining tasks

  1. Update the comment as noted in #96.
  2. Update the issue summary, to clarify what changes this issue makes. (?) Seems really clear already.
  3. RTBC
  4. Commit
  5. Unblock progress on #2648950: [PP-2] Use form element of type date instead textfield when selecting a date in an exposed filter

User interface changes

If an exposed filter requires multiple form elements, add a wrapper around the whole thing and use the field label as the legend for that wrapping fieldset. This allows the label for the field itself to be visible, ensures all the elements related to the same field are grouped together (both visually and in the form structure), and allows the sub elements to all have visible labels.

Cases where an exposed filter require multiple elements include:

  • The operator is exposed.
  • The operator is fixed but requires multiple elements (e.g. "Between" and "Not between").

Screenshots: Before

Screenshots: After

API changes

None.

Release notes snippet

Views exposed filters that involve multiple form elements are now wrapped in a fieldset. For example, this applies to numeric filters with a 'Between' operator, or any filter with an exposed operator. The filter label is now always visible, as the fieldset legend, and any included elements are nested inside.

This significantly improves the user interface for both sighted users and people using assistive technology. However, this means that the form structure of the exposed filter form is changed. Sites that implement hook_form_alter() to modify the exposed filter form may have to update that implementation to handle the changed form structure. See the change record for details.

CommentFileSizeAuthor
#147 2625136.129_146.interdiff.txt865 bytesdww
#147 2625136-146.patch6.42 KBdww
#147 2625136-146.2-exposed-between-before.png79 KBdww
#147 2625136-146.exposed-between-before.png29.67 KBdww
#130 2625136-129.bartik-already-wonky.png55.36 KBdww
#130 2625136.115_129.interdiff.txt628 bytesdww
#130 2625136-129.patch6.41 KBdww
#124 claro_after.png9.03 KBrensingh99
#124 seven_after.png10.56 KBrensingh99
#124 bartik_after.png10.26 KBrensingh99
#124 claro.png5.3 KBrensingh99
#124 bartik.png9.85 KBrensingh99
#124 seven.png15.61 KBrensingh99
#115 2625136.112_115.interdiff.txt1.54 KBdww
#115 2625136-115.8_7_x.patch6.43 KBdww
#115 2625136-115.8_8_x.patch6.42 KBdww
#112 2625136.103_112.interdiff.txt2.39 KBdww
#112 2625136-112.8_7_x.patch6.44 KBdww
#112 2625136-112.8_8_x.patch6.43 KBdww
#103 2625136.76_103.rawdiff.txt919 bytesdww
#103 2625136-103.8_7_x.patch5.21 KBdww
#103 2625136-103.8_8_x.patch5.21 KBdww
#103 2625136-103.8_9_x.patch5.21 KBdww
#97 Screenshot from 2018-11-20 13-42-22.png3.17 KBmatsbla
#97 Screenshot from 2018-11-20 13-42-19.png2.82 KBmatsbla
#87 Screenshot from 2018-09-14 16-03-57.png3.27 KBmatsbla
#87 Screenshot from 2018-09-14 16-03-53.png2.1 KBmatsbla
#76 interdiff-2625136-73-76.txt1.01 KBkevin.dutra
#76 drupal-label_visibility_for-2625136-76.patch5.24 KBkevin.dutra
#73 interdiff-2625136-63-73.txt2.13 KBkevin.dutra
#73 drupal-label_visibility_for-2625136-73.patch5.29 KBkevin.dutra
#67 bartik_-_after.png33.23 KBplach
#67 bartik_-_before.png35.77 KBplach
#67 seven_-_before.png45.03 KBplach
#67 seven_-_after.png51.57 KBplach
#63 2625136-63.patch4.81 KBjofitz
#59 interdiff.txt1.62 KBkevin.dutra
#59 drupal-label_visibility_for-2625136-59.patch4.64 KBkevin.dutra
#57 interdiff.txt3.53 KBkevin.dutra
#57 drupal-label_visibility_for-2625136-57.patch5.69 KBkevin.dutra
#55 interdiff.txt14.04 KBkevin.dutra
#55 drupal-label_visibility_for-2625136-55.patch3.99 KBkevin.dutra
#49 interdiff.txt762 bytessukanya.ramakrishnan
#49 drupal-label_visibility_for-2625136-49.patch18.42 KBsukanya.ramakrishnan
#47 drupal-label_visibility_for-2625136-47.patch13.39 KBsukanya.ramakrishnan
#44 drupal-label_visibility_for-2625136-44.patch13.33 KBsavkaviktor16@gmail.com
#38 drupal-label_visibility_for-2625136-38.patch11.74 KBheddn
#35 drupal-label_visibility_for-2625136-33.patch11.74 KBheddn
#35 interdiff_33-35.txt970 bytesheddn
#33 interdiff_32-33.txt1.12 KBheddn
#33 label_visibility_for-2625136-33.patch11.65 KBheddn
#32 interdiff_29-32.txt1.13 KBheddn
#32 label_visibility_for-2625136-32.patch10.99 KBheddn
#30 multiple.png4.38 KBheddn
#30 single.png2.35 KBheddn
#29 multiple-operator.png7.87 KBheddn
#29 multiple.png5.5 KBheddn
#29 single-operator.png6.62 KBheddn
#29 single.png2.87 KBheddn
#29 label_visibility_for-2625136-29.patch10.82 KBheddn
#28 multiple-exposed.png5.44 KBheddn
#28 multiple.png5.5 KBheddn
#28 single-exposed.png3.86 KBheddn
#28 single.png2.87 KBheddn
#24 interdiff_20-23.txt1.01 KBheddn
#24 label_visibility_for-2625136-23.patch9.96 KBheddn
#22 label_visibility_for-2625136-21.patch9.82 KBheddn
#22 interdiff_20-21.txt817 bytesheddn
#20 interdiff_17-20.txt913 bytesheddn
#20 label_visibility_for-2625136-20.patch9.96 KBheddn
#17 interdiff_16-17.txt1.69 KBheddn
#17 label_visibility_for-2625136-17.patch9.86 KBheddn
#16 label_visibility_for-2625136-16.patch10.75 KBheddn
#12 label_visibility_numeric_field-2625136-12.patch10.47 KBfinne
#4 single operator exposed.png12.17 KBfinne
#4 operator not exposed.png11.75 KBfinne
proposed fix.png35.16 KBfinne
multiple values operator exposed.png36.02 KBfinne
single operator exposed.png14.88 KBfinne
operator not exposed.png16.23 KBfinne
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

finne created an issue. See original summary.

finne’s picture

Issue summary: View changes
finne’s picture

Issue summary: View changes
finne’s picture

Issue summary: View changes
FileSize
11.75 KB
12.17 KB
finne’s picture

finne’s picture

finne’s picture

finne’s picture

Issue summary: View changes
finne’s picture

Issue summary: View changes
finne’s picture

finne’s picture

finne’s picture

This patch implements the proposed 5 resolutions. It has tests for the 5 resolutions. It incorporates the resolution of #2480719: Missing label and description for exposed numeric filter when using 'between' filter.

finne’s picture

Status: Needs work » Needs review
finne’s picture

Issue summary: View changes

Patch passes. I have briefly discussed the changes with @dawehner at #dcvie and he agreed this would be a good solution for now.

dawehner’s picture

  1. +++ b/core/modules/views/src/Plugin/views/filter/NumericFilter.php
    @@ -114,6 +115,22 @@ function operators() {
    +      $form['operator']['#prefix'] = '<span class="views-filter-wrapper views-filter-' . Html::cleanCssIdentifier($this->options['expose']['identifier']) . '">';
    

    I'm wondering whether there is any way we could move that HTML into the template level? I guess no, because core/modules/views/templates/views-exposed-form.html.twig is not dealing with that level of detail at the moment.

  2. +++ b/core/modules/views/src/Plugin/views/filter/NumericFilter.php
    @@ -186,9 +205,9 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
    -        '#title' => !$exposed ? $this->t('Value') : '',
    +        '#title' => $exposed ? '' : $this->t('Value'),
             '#size' => 30,
    -        '#default_value' => $this->value['value'],
    +         '#default_value' => $this->value['value'],
    

    These changes aren't really strictly needed, right?

heddn’s picture

Version: 8.0.x-dev » 8.2.x-dev
Assigned: finne » Unassigned
Priority: Minor » Normal
FileSize
10.75 KB

Strait re-roll before I start working on feedback. I'm moving to a normal priority. It should get fixed as it makes these exposed filters very ugly and is a regression from D7.

heddn’s picture

The last submitted patch, 16: label_visibility_for-2625136-16.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 17: label_visibility_for-2625136-17.patch, failed testing.

heddn’s picture

heddn’s picture

Status: Needs work » Needs review
heddn’s picture

The last submitted patch, 20: label_visibility_for-2625136-20.patch, failed testing.

heddn’s picture

+++ b/core/modules/views/src/Plugin/views/filter/NumericFilter.php
@@ -230,10 +230,9 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
-        '#field_prefix' => $exposed ? $this->t('and') : '', // Add separating label.

This doesn't seem necessary.

The last submitted patch, 22: label_visibility_for-2625136-21.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 24: label_visibility_for-2625136-23.patch, failed testing.

heddn’s picture

I did some manual testing of this and I think at this point, the test might be wrong. Pursuing that theory.

heddn’s picture

Issue summary: View changes
FileSize
2.87 KB
3.86 KB
5.5 KB
5.44 KB

So, what was missing in the scenarios was when you had multiple, without an exposed operator. I've taken a pass updating the IS with what I think should be done. Essentially, we do what was done in D7.

heddn’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
10.82 KB
2.87 KB
6.62 KB
5.5 KB
7.87 KB

Updates IS with screenshots of actual D8 site with changes from this patch. Tests aren't updated yet so will likely fail. Started out with a fresh patch by comparing against D7 and using a fieldset form wrapper for all but the simple single value, so no interdiff.

heddn’s picture

Issue summary: View changes
FileSize
2.35 KB
4.38 KB

Status: Needs review » Needs work

The last submitted patch, 29: label_visibility_for-2625136-29.patch, failed testing.

heddn’s picture

Fixed the last annoying thing in the filter admin form. It wasn't in sync with the exposed filter form and was confusing. Next up is fixing the tests. If someone gets to it before me, go ahead.

Overall, we're in a much better place. However, at some point, we should go through and clean-up the numeric filter form logic. It is rather more complicated than I think it needs to be.

heddn’s picture

Status: Needs work » Needs review
FileSize
11.65 KB
1.12 KB

Status: Needs review » Needs work

The last submitted patch, 33: label_visibility_for-2625136-33.patch, failed testing.

heddn’s picture

Status: Needs work » Needs review
FileSize
970 bytes
11.74 KB

The remaining failures are due to the form not getting loaded with all 3 input boxes on config form load. So when an administrator changes to 'between', the two extra Max/Min fields don't show up until you save and revisit the config form. I'll see if I can get time to fix that, but for me it is a trivial UX bug and the filters work. So if someone has interest, please proceed.

This last patch should fix up the schema config validation failure.

Status: Needs review » Needs work

The last submitted patch, 35: drupal-label_visibility_for-2625136-33.patch, failed testing.

The last submitted patch, 35: drupal-label_visibility_for-2625136-33.patch, failed testing.

heddn’s picture

Status: Needs work » Needs review
FileSize
11.74 KB

The last submitted patch, 33: label_visibility_for-2625136-33.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 38: drupal-label_visibility_for-2625136-38.patch, failed testing.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jhedstrom’s picture

Issue tags: +Needs reroll

Patch doesn't seem to apply any more.

savkaviktor16@gmail.com’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
13.33 KB

Patch was re-rolled. It was resolved merge conflicts related to the short array syntax, which replaces array() with [];
It was also fixed some simple issues related to coding standards.

Status: Needs review » Needs work

The last submitted patch, 44: drupal-label_visibility_for-2625136-44.patch, failed testing.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

sukanya.ramakrishnan’s picture

Patch didnt apply to 8.4, figured that the test structure has changed to tests/src/Functional.

Submitting corrected patch.

sukanya.ramakrishnan’s picture

am trying to look into the test failures and there is some problem with the code changes in this patch. For a grouped filter, when 'in between' is chosen as operator, only one form field is present, not two as expected on Drupal 8.4 .

Oops, not just for grouped filters, even for single filters, the in between filters are not working..

Ok this issue has been noted earlier in #35. It seems like some issue in the code with the way #states is being set.

Thanks,
Sukanya

sukanya.ramakrishnan’s picture

Submitting updated patch and interdiff.
Lets see what the testbot thinks now.

sukanya.ramakrishnan’s picture

sukanya.ramakrishnan’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 49: drupal-label_visibility_for-2625136-49.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

sukanya.ramakrishnan’s picture

Charles Belov’s picture

Does the word "operator" need to appear in the UI? It's apparent from the content that it is an operator.

I would expect:

Salary
is less than

or

Salary
is between
min
and
max

"Operator" probably does belong as a label under the hood as a label for screen readers.

That said, since the field is aimed at site visitors, I wonder whether "Operator" is too technical, and, if it is going to show, whether it might better read "Comparison".

kevin.dutra’s picture

Status: Needs work » Needs review
FileSize
3.99 KB
14.04 KB

Although the Numeric/Date filters may highlight the problem, I think this is wider spread than any one filter type. In a general sense, there is no logical grouping of the operator and value forms that would make it intuitive for a screen reader or possible to target styling. FWIW, I also tend to agree with @Charles Belov in that the "Operator" label is unhelpful.

Trying to manipulate the operator form from within the value form also feels wrong to me. I've also been having trouble getting the patch to work correctly with Drupal since about 8.2 (although it applies cleanly).

Accordingly, I'm adding this patch as a potential alternative approach that is a bit more generic. There are a few of the existing code style fixes that are in the area where changes are targeted. I haven't invested in writing any tests yet — until an approach is decided on, it seems like it would be wasted effort.

Status: Needs review » Needs work

The last submitted patch, 55: drupal-label_visibility_for-2625136-55.patch, failed testing. View results

kevin.dutra’s picture

Status: Needs work » Needs review
FileSize
5.69 KB
3.53 KB

Adjustments for test failure & filters that have value forms with multiple elements.

jhedstrom’s picture

+++ b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php
@@ -850,6 +849,17 @@
+      // When the operator and value forms are both in play, enclose them within
+      // a wrapper, for usability.
+      if (!empty($this->options['expose']['identifier'])) {

I wonder if a change notice is needed for this? Since it fixes a bug, probably not, but I suppose there is a chance custom themes have already worked around this and the wrapper might impact those developers.

As mentioned in #15, while nice, these coding standards fixes below are out of scope for this issue (and will be fixed when the relevant coding standards issue gets committed).

+++ b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php
@@ -830,9 +830,8 @@
-   * Render our chunk of the exposed filter form when selecting
+   * Render our chunk of the exposed filter form when selecting.

+++ b/core/modules/views/src/Plugin/views/filter/NumericFilter.php
@@ -130,8 +130,9 @@ class NumericFilter extends FilterPluginBase {
-   * Provide a simple textfield for equality
+   * Provide a simple textfield for equality.

@@ -149,7 +150,7 @@ class NumericFilter extends FilterPluginBase {
-        // exposed and locked.
+        // Exposed and locked.

@@ -227,7 +227,7 @@ class NumericFilter extends FilterPluginBase {
-          '#value' => NULL
+          '#value' => NULL,

These coding standard cleanup changes, while nice, are probably out of scope

+++ b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php
@@ -830,9 +830,8 @@
-   * Render our chunk of the exposed filter form when selecting
+   * Render our chunk of the exposed filter form when selecting.

+++ b/core/modules/views/src/Plugin/views/filter/NumericFilter.php
@@ -130,8 +130,9 @@ class NumericFilter extends FilterPluginBase {
-   * Provide a simple textfield for equality
+   * Provide a simple textfield for equality.

@@ -149,7 +150,7 @@ class NumericFilter extends FilterPluginBase {
-        // exposed and locked.
+        // Exposed and locked.

@@ -227,7 +227,7 @@ class NumericFilter extends FilterPluginBase {
-          '#value' => NULL
+          '#value' => NULL,
SylvainM’s picture

Status: Needs review » Reviewed & tested by the community

I have this patch working from several months, thank you

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 59: drupal-label_visibility_for-2625136-59.patch, failed testing. View results

mpdonadio’s picture

Issue tags: +Needs reroll
jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
4.81 KB

Re-rolled.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

avogler’s picture

Status: Needs review » Reviewed & tested by the community

Manually tested it and it works as expected. Code changes look goog to me.

plach’s picture

+++ b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php
@@ -880,6 +891,40 @@ public function buildExposedForm(&$form, FormStateInterface $form_state) {
+  protected function buildValueWrapper(&$form, $wrapper_identifer) {
+    if (!isset($form[$wrapper_identifer])) {
+      $form[$wrapper_identifer] = [

I'm not sure about this line: if I'm not mistaken, we are silently skipping the wrapper if one element with the same ID already exists. IMO this may result in poor DX/TX, as one may not realize why the wrapper is not showing up, without inspecting the form array structure. Given that such collision should happen only if some code is altering the form and injecting a conflicting element (the Views UI won't allow conflicting IDs), I'm wondering whether it would make sense to add an else branch throwing an exception.

plach’s picture

Issue summary: View changes
FileSize
51.57 KB
45.03 KB
35.77 KB
33.23 KB

Added before/after screenshots.

plach’s picture

Issue tags: +Needs usability review

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 63: 2625136-63.patch, failed testing. View results

Lendude’s picture

Status: Needs work » Reviewed & tested by the community

Unrelated fails

alexpott’s picture

Status: Reviewed & tested by the community » Needs review

#66 needs answering.

  1. +++ b/core/modules/views/src/Plugin/views/filter/NumericFilter.php
    @@ -260,17 +260,16 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
    -        '#title' => !$exposed ? $this->t('Min') : $this->exposedInfo()['label'],
    +        '#title' => $this->t('Min'),
    

    Are we sure about losing the ability to customise this?

  2. +++ b/core/modules/views_ui/tests/src/Functional/FilterNumericWebTest.php
    @@ -109,10 +109,10 @@ public function testFilterNumericUI() {
    -    $this->assertRaw('<label for="edit-age-min">Age between</label>', 'Min field label found');
    

    This label is set up above - $edit['options[expose][label]'] = 'Age between'; what happens to it now?

kevin.dutra’s picture

Assigned: Unassigned » kevin.dutra
Status: Needs review » Needs work

In regard to #6, that seems like a fair point. I'll toss an exception in there.

  1. The label that used to be applied to the Min input element now adorns the wrapper (and is still based on configuration). You already cannot customize the Max label, so we're now making it consistent across both of those elements. Moreover, currently when you expose the operator, the Min input element is the only thing that gets the field label, so if the end user switches to "equal to" instead, the field label completely disappears from screen because it's tied to the Min element only, which presents poor UX. So it's true that there is a slight trade-off, but I'd argue that the gains substantially outweigh the loss.
  2. I'll add in a check for that existing on the wrapper.
kevin.dutra’s picture

Here are those couple tweaks. As long as we're already touching those assertions, I went ahead and made deprecation adjustments.

kevin.dutra’s picture

Assigned: kevin.dutra » Unassigned

Status: Needs review » Needs work

The last submitted patch, 73: drupal-label_visibility_for-2625136-73.patch, failed testing. View results

kevin.dutra’s picture

Ah, now I'm sort of remembering why that bit was in there in the first place:

The wrapper has to exist to be able to put the input elements into it. If you've both exposed the field and the operator, then the method gets invoked twice. (see buildExposedForm() -- build the wrapper, put the operator in it, build the wrapper, put the field in it.) We don't want the previous contents of the wrapper to be wiped out on that second pass, hence why it had that check.

davidwhthomas’s picture

Just want to note, the patch in #76 fixed the issue we were having with Views exposed filters, operators, labels and grouping, with thanks.
One issue was it doesn't work with the "better_exposed_filters" module (maybe as we used the custom, shorter filter name in the view setting), but as we can use the default exposed filter plugin, it's fine, thanks.

jhedstrom’s picture

Issue tags: +Needs change record

One issue was it doesn't work with the "better_exposed_filters" module (maybe as we used the custom, shorter filter name in the view setting)

My guess is it doesn't work with BEF jquery date plugin?

I think this means this issue needs a change record. Aside from that, I think the patch in #76 has addressed the remaining issues from #71 and can be RTBC pending a CR.

GoZ’s picture

Assigned: Unassigned » GoZ
Issue tags: +DevDaysLisbon

I'm going to write the change record

GoZ’s picture

Assigned: GoZ » Unassigned

Change record available https://www.drupal.org/node/2984152

caspervoogt’s picture

#76 is working for me

jhedstrom’s picture

Status: Needs review » Reviewed & tested by the community

I think this is now RTBC.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

GoZ’s picture

I move change record to 8.7.x

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 76: drupal-label_visibility_for-2625136-76.patch, failed testing. View results

AaronBauman’s picture

Status: Needs work » Needs review

Failing test does not look related, let's try again.

matsbla’s picture

Status: Needs review » Needs work
FileSize
2.1 KB
3.27 KB

I tested patch in #76 and I found no problems using it together with Better Exposed Filters.
The tests also pass now.

However, I tested patch in #76 together with patch in #166 here, which is also on the way into core: #2648950-166: [PP-2] Use form element of type date instead textfield when selecting a date in an exposed filter
When I apply the patches together the containing span for the filters are gone again, so this:
Screenshot with this patch applied
Becomes like this:
Screenshot with this patch applied with patch in comment 166 in #2648950

AaronBauman’s picture

Thanks for the detailed report and screenshots.
While I that this conflict will have to be resolved eventually, I think this issue should be reviewed independently.
We can't anticpate how the other thread will be resolved, and it's not practical to maintain compatibility between multiple separate issues unless they are hard dependencies. Further, since this is a patch to the base class, maybe 2648950 should actually be postponed on this issue.

Regardless, if 2648950 is committed first, we'll have to update this patch.
If this patch is committed first, 2648950 will have to be updated.

I'm coming in late to this thread - does this approach make sense?
In general, I think that's the standard approach to take.
If so, please reset to "needs review"
Is there other context with this issue that I'm missing?

matsbla’s picture

Status: Needs work » Reviewed & tested by the community

I don't know what is the best approach, but as it was already set to RTBC before the tests failed, I put it back again, and I guess we'll find out.

dww’s picture

Issue tags: -Needs change record

CR is at https://www.drupal.org/node/2984152 so removing that tag.

I'm not sure if "Needs usability review" is still valid or not. That was requested in #68 and not really addressed since. It seems like this is an improvement on an existing and obvious UI bug. I'd rather perfect not become the enemy of good, but if this needs more formal review/testing/sign-off, so be it. I'll leave it at RTBC and let a core committer decide.

Thanks,
-Derek

codesmith’s picture

I applied the patch in #76 on a Drupal 8.6.2 site and it's working as expected. Thank you! Much improved UI.

benjifisher’s picture

I plan to bring this up at the weekly Usability meeting in about 4 hours (3:30 PM EST). Join us on the #ux channel in the Drupal Slack account if you would like to be part of the discussion.

worldlinemine’s picture

At the Drupal Usability meeting we reviewed the suggested patches (participating Benji Fisher and Thomas Howell).

Change examined at "Structure" -> "Views" -> "Content"

Testing patch results:
Testing was a bit time consuming. We added the “changed” filter to the Content page for administration installed by the standard profile. Testing revealed that Tab order hasn’t changed with the addition of the patch.

Follow up questions:

  1. Including everything in the field set is suspected to improve or maintain the current state of accessibility for this scenario but further testing is advised to confirm.
  2. Could the alignment be improved for Bartik?

Conclusion:
Despite the possibility of a few outstanding improvements for alignment and labeling we feel that this patch is a clear usability win and we don’t view the absence of those potential improvements as blockers.

worldlinemine’s picture

Issue tags: -Needs usability review
benjifisher’s picture

Title: label visibility for exposed numeric and date filter when using single and multi value filter » label visibility for exposed numeric/date filters with exposed operators

As @worldlinemine said, we discussed this at the Drupal Usability Meeting 2018-11-13 (recording on Youtube). This issue looks like a clear improvement.

I would like to see an accessibility review just in case there is a problem we did not notice.

One thing that slowed us down a bit was that the title did not make clear that the change only affects exposed filters with exposed operators. I see that the CR explicitly mentions the operator. I will update the title to clarify this, but I expect someone who has worked on this issue may want to refine my change.

catch’s picture

+++ b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php
@@ -880,6 +891,43 @@ public function buildExposedForm(&$form, FormStateInterface $form_state) {
+      // a wrapper, for usability. Also wrap if the value form is comprised of

I don't think we should say 'for usability' here, we should try to explain what the visual difference is or similar, or maybe just remove the 'for usability' bit - git blame will lead people to this issue for justification.

matsbla’s picture

> the change only affects exposed filters with exposed operators

I don't think so, the change also affect cases where there is no exposed operator.
As example, if you use daterange fields, and choose the "Is between" operator the label look like this now:

Before

And after applying patch in #76 it looks like this:

After

benjifisher’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs issue summary update

I am setting this back to NW because of the discussion in #96 and #97. I will update the remaining tasks in the issue summary.

dww’s picture

Title: label visibility for exposed numeric/date filters with exposed operators » label visibility for exposed numeric/date filters with multiple form elements
Issue summary: View changes

More accurate title, minor edits to the summary (we already have all the screenshots we need, right?).

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

tseven’s picture

Any resolution in sight for this bug?

What are the chances of a fix being included in the next version?

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

dww’s picture

I fixed the comment requested by @catch in #96.

I've re-rolled clean patches for 8.9.x, 8.8.x and 8.7.x. The 8.9.x and 8.8.x patches are identical, but for clarity I'm naming them and attaching them separately (to keep testbot, committers, and anyone applying these via composer on the right track).

I've re-reviewed the summary and I think it's totally clear. I'm not sure what else we can do to improve the description of what this is changing. Removing that tag.

Interdiff is confused, so I'm attaching a raw diff of #76 vs. the 8.7.x patch in here.

This is blocking #2648950: [PP-2] Use form element of type date instead textfield when selecting a date in an exposed filter, so I'd love to see it land soon. Ideally before 8.8.0-beta1. Not sure if it's a candidate for an 8.7.x backport.

Thanks!
-Derek

dww’s picture

Bot is fully happy, as expected.
I also updated the CR: https://www.drupal.org/node/2984152
Added an after screenshot, clarified when the wrapper is added, fixed some typos + grammar errors, etc. I think it's ready to publish.

RTBC?

Thanks!
-Derek

dww’s picture

p.s. Yes, this is really what core looks like without this fix:

 bad UI

Tempted to promote this to 'major UI bug', but I think that'd violate the priority guidelines:

Bugs that affect one piece of functionality and are self-contained are normal priority.
They do not impact the overall functionality of the software.
Examples of normal bugs:

  • Bugs for site visitors that do not interfere with site use, for example, visual layout issues.

Anyway, certainly "important", if not officially "major". ;)

jibran’s picture

I wasted too much time fixing this on a client project. The patch looks clean & to the point, tests look good, change notice is also clear and mentions what needed to be done to update the code to hide #date_time_element so it is RTBC for me.

Yeah, I wouldn't say it is major but is certainly annoying. :D Thank you for picking it up.

jibran’s picture

Status: Needs review » Reviewed & tested by the community
dww’s picture

Title: label visibility for exposed numeric/date filters with multiple form elements » Fix label visibility and add wrapper element for exposed numeric/date filters with multiple form elements
Issue summary: View changes

Thanks for the review and RTBC!

Slightly better title to hopefully further clarify.

Updates to the UI changes section of the summary to be even more explicit.

Hope this lands soon... :)

Thanks,
-Derek

dww’s picture

Title: Fix label visibility and add wrapper element for exposed numeric/date filters with multiple form elements » Fix label visibility and add wrapper container for exposed numeric/date filters with multiple form elements
Lendude’s picture

Status: Reviewed & tested by the community » Needs work

Great work on this! Important fix so hate to un-RTBC this but got a couple of things I think we need to answer:

  1. +++ b/core/modules/views_ui/tests/src/Functional/FilterNumericWebTest.php
    @@ -108,11 +108,13 @@ public function testFilterNumericUI() {
    +    $this->assertSession()->responseContains('<label for="edit-age-max">Max</label>');
    +    $this->assertSession()->responseContains('<label for="edit-age-min">Min</label>');
    

    Can we make the test coverage so that it actually tests that the min/max elements are nested inside the wrapper and not just test that they are on the page?

  2. +++ b/core/modules/views_ui/tests/src/Functional/FilterNumericWebTest.php
    @@ -108,11 +108,13 @@ public function testFilterNumericUI() {
    +    self::assertEquals(trim($this->cssSelect('#edit-age-wrapper--description')[0]->getText()), 'Description of the exposed filter');
    

    Core doesn't do self::assertEquals but $this->assertEquals (long story)

Do we need test coverage to assert that the wrapper isn't shown on non-two-value exposed filters? Or do we have existing coverage for that? did somebody check?

dww’s picture

Assigned: Unassigned » dww

@Lendude Thanks for the review! Re: #110

1. Yes, probably. ;) Can probably be done pretty easily via xpath selectors.

2. Yeah, I sorta knew that. Any chance there's a link to that long story somewhere so I can understand it better? Regardless, easy to fix.

3.

Do we need test coverage to assert that the wrapper isn't shown on non-two-value exposed filters?

Probably. ;)

Or do we have existing coverage for that? did somebody check?

Dunno, didn't check. ;) I'll look now.

I'll take a stab at all of the above, stay tuned.

Cheers,
-Derek

dww’s picture

dww’s picture

p.s. To be explicit: This patch is adding the fieldset, so I don't see how there could be existing test coverage related to the fieldset anywhere else in core. Therefore, since there was no coverage of the "shouldn't need a fieldset" case in #103, it seems safe to assume there was no coverage of that. Hence, I added some to the bottom of the test case. ;)

p.p.s. It *does* seem kinda weird that we're testing all this inside a views_ui test, relying on the 'Update preview' button, etc, but a) this test already lived there and needed to be updated to change the labels it was looking for and b) seems better to just finish testing everything related to the labels + (conditional) fieldsets in the same test, instead of adding a whole new Functional test in core/modules/views/tests/... for this. Refactoring all these filter-related views tests is totally out of scope for this issue, so I'm just updating/fixing/expanding the existing test method, even though I don't personally think what's in #112 is ideal.

Thanks,
-Derek

jibran’s picture

Status: Needs review » Reviewed & tested by the community

The new test coverage looks great. Back to RTBC as #110 is addressed.

dww’s picture

+++ b/core/modules/views_ui/tests/src/Functional/FilterNumericWebTest.php
@@ -108,11 +108,34 @@ public function testFilterNumericUI() {
+    $this->assertTrue(!empty($min_element_label));

Was thinking about these new test assertions, and to be even more careful/safe, assertCount()would be better. That would save us from a bug that introduced duplicate labels or something...

Super trivial change. I'm going to leave this as RTBC (but will queue the bot for full testing).

Lendude’s picture

@dww nice!

The self:: vs $this discussion can be found here https://github.com/sebastianbergmann/phpunit/issues/1914

dww’s picture

Issue tags: +blocker

@Lendude Thanks for the link! Started skimming, but need to do other things right now. I'll read in detail ASAP.

Since this is blocking other issues, also tagging for "blocker".

Did a final pass to edit the CR for clarity:
Exposed numeric/date views filters with multiple elements now have a wrapper, update form structure

https://www.drupal.org/node/2984152/revisions/view/11619541/11622827

Currently written as if this will be backported to 8.7.x, which might not happen. So when that's published, be sure to get the version + branch right based on where this lands.

Thanks, everyone!
-Derek

lauriii’s picture

Status: Reviewed & tested by the community » Needs review

I'm a bit concerned about the potential disruption for existing sites. I'm wondering if someone could be relying on the current behavior. We probably should at least document on the change record how someone would get the old behavior back if that's what they want.

dww’s picture

Yeah, this change is indeed quite disruptive. But core's current behavior is so broken, we have to do something. If our policy ends up saying "people are probably already working around this bug, so we can't fix it", that seems really sad. So, we wait for a "major" version upgrade to fix it. But then we find out that our "major" version is also supposed to be "BC" + "non-disruptive" (except for removing dead code that wouldn't break anything if you've been keeping up with all the API changes in all the "minor" releases), so we can't fix it there, either. ;) Then us bug hunters despair at the state of Drupal and feel like we're trying to tame a wild beast with 2 hands and foot tied behind our backs... ¯\_(ツ)_/¯

I can't think of a particularly clean/easy way for sites to get the mess back and remove the fieldsets. This markup is deep inside views/src/Plugin/views/filter/FilterPluginBase.php and there's no twig template involved. Can the CR suggest that sites that want to restore the bug can apply the patch in reverse to re-break it? ;)

Also, I've learned from Andrew at #3078334: Datetime and Datelist elements should render as fieldsets that fieldset is the preferred solution for grouping related form items together for accessibility reasons. So we could probably consider this an accessibility improvement bugfix and relax our BC standards in this case. Tagging for an accessibility review. I just re-read the summary and I think it's all accurate for reviewing the bug + proposed resolution. Given how absurd the current markup is for sighted users, I can only imaging how confusing this would be for someone using a screen reader. :(

I'd be really sad to have to write a BC layer, an opt-in new setting to get a working UI, an upgrade path to set existing sites to "use-broken-UI-for-exposed-forms = TRUE", and upgrade tests, all so that folks that already fixed this bug don't have to let core fix it for them for real.

And, I freely admit this is disruptive, changes the form structure, custom form_alter on your exposed filters will stop working, etc, etc. We're totally in a bind. I feel your pain about wanting to minimize disruption to existing sites.

I'm going to wait to edit the CR until we get clarity on what we're recommending (if anything) for sites to do to restore the broken UI, and if this will be fixed in 8.9.x, 9.0.x, 10.x, never, etc. ;)

Cheers,
-Derek

jhedstrom’s picture

I'm a bit concerned about the potential disruption for existing sites.

Fortunately, any site currently with a workaround should be using this patch, so the disruption would be minimal hopefully.

jweakley’s picture

Hey dww, I have applied the patch on a local VM and I see no changes to my text view I made... willing to troubleshoot with you.
Here's a YouTube video of my screen recording.

jweakley’s picture

I have tested core on a local virtual machine and confirmed there are several accessibility, and indeed UI/UX, issues when utilizing an exposed filter with exposed operators for date selection for the 'Authored on' and 'Published on' field filters. Specifically, there is no label generated at all in the unpatched scenario, and there is little to no indication that the date field is related to the filter. This patch from user dww addresses these items. Most helpful in this patch is that it places all the div elements of each filter in their own "fieldset" container and provides the label for the filter as a "legend". Using a screen reader after the patch was installed locally it is much better when navigating with the keyboard (tab and arrow keys). When using keyboard navigation the order is much more logical and all fields can be discerned better than before. I would encourage this patch to be adopted and further enhancements for accessibility and UI/UX to be made by the community. Specific enhancements that could be made would be a help text field as well as the description. An example of very good use of help text and descriptions can be found in the Webform module.

dww’s picture

Priority: Normal » Major
Issue summary: View changes

Thanks for the review @jweakley! Based on our Slack chat about this, I added a Key UI/UX/Accessibility bugs fixed by this issue section to the summary. Also, escalating this bug to major, since based on your review, the existing UI is basically unusable for folks using assistive technologies.

Still wondering what exactly I can/should put in the CR to address "how someone would get the old behavior back if that's what they want." per @lauriii in #118. Based on how this fix works, restoring the broken/inaccessible behavior is not easy, short of patch -p1 -R < 2625136-115.8_8_x.patch. ;)

Not sure if we can remove the 'Needs accessibility review' tag, yet. Perhaps one of the more "official" accessibility maintainers for core should comment here, too...

Thanks,
-Derek

p.s. Crediting @jweakley for all the effort spent reviewing/testing this for accessibility.

rensingh99’s picture

FileSize
15.61 KB
9.85 KB
5.3 KB
10.26 KB
10.56 KB
9.03 KB

Hi,

I have checked the patch #2625136-115.8_8_x.

There are some problems with Bartik and the claro theme.

Below is an output screenshot before applying the patch for Bartik, Seven and Claro.

Below is an output screenshot after applying the patch for Bartik, Seven and Claro.

Thanks,
Ren

dww’s picture

@rensingh99 re: #124:

A) Can you clarify what you think the problem is? Those screenshots look exactly as expected. A red box doesn't communicate your concerns. ;)

Are you worried that the fieldsets aren't pixel-perfectly styled? If anything, the Claro screenshot seems worse than the other two on that front. If we need to *also* add CSS tweaks to all the core themes to try to make this look "perfect", that seems a bit scope-creepy to me (and yet more potential to disrupt existing sites). In fairness, Claro didn't even exist when this issue and fix was written, and Claro is still experimental, so IMHO fixing Claro should be a follow-up issue in the Claro queue, not here. But perhaps the core committers would be more comfortable if we do all that work as part of this issue. TBD.

B) Your comment says "Below is an output screenshot before applying the patch for Bartik, Seven and Claro." twice. The 2nd was for after the patch, no? Maybe you want to edit your comment to avoid confusion?

rensingh99’s picture

Hi @dww

Thank you for your comment.

A) In Bartik, the number text field is not inline with the operator field. it's coming with some space(about 2px).

And in claro yes fieldset is not pixel-perfectly styled.

B) I have edited the comment #124.

Thanks,
Ren

clivesj’s picture

Status: Needs review » Reviewed & tested by the community

I am using the patch on several sites and this works very well.
Everything that is not 100% perfect is fixed with a little css.
For me this is RTBC to prevent this to drag om forever.

The last submitted patch, 115: 2625136-115.8_8_x.patch, failed testing. View results

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

dww’s picture

Version: 9.1.x-dev » 8.9.x-dev
Status: Reviewed & tested by the community » Needs review
Issue tags: -Needs accessibility review
FileSize
6.41 KB
628 bytes
55.36 KB

A) As an accessibility bugfix, I think this should still be backported at least to 8.9.x. I suspect that given the potential disruption, it's not going to be landing in 8.8.x, but there's still time to fix 8.9.x and up. Good news is that the same patch applies to all the active branches now.

B) Re: Claro -- I think that needs to be a follow-up. Claro is still experimental, and a work-in-progress. There's a whole process to get designs approved. I don't think we should delay this fix while that unfolds.

C) Re: Bartik -- the spacing between text fields and selects is already a bit wonky, without this patch. That's nothing new. I don't think it makes sense to do a "pixel perfect" fix for this one case, and fixing it in general is way out of scope here. People who care about that have already fixed it for themselves. The form elements all have identical margins. The only difference is the height of the elements. Here's a screenshot of the /admin/content page on a clean 8.8.x install with Bartik set as the admin theme. You can see the same height differences:

Screenshot of /admin/content with Bartik as the admin theme, showing uneven heights of text fields vs. selects

D) Test fail on #115 for 8.8.x was a random fail:

There was 1 error:

1) Drupal\Tests\field_ui\FunctionalJavascript\ManageDisplayTest::testWidgetUI
WebDriver\Exception\CurlExec: Curl error thrown for http POST to http://chromedriver-jenkins-drupal-patches-43824:9515/session/2e90493961ddfbd2724749f8c87b00a0/execute with params: {"script":"(function (element) {\n    var event = document.createEvent(\"HTMLEvents\");\n\n    event.initEvent(\"drop\", true, true);\n    event.dataTransfer = {};\n\n    element.dispatchEvent(event);\n}(arguments[0]));","args":[{"ELEMENT":"0.6472767889402347-5"}]}

E) Inspired by #3128573: [meta] Replace assertions with more appropriate ones decided to fix one of the test assertions to be more appropriate. ;) See interdiff. However, since it's a reroll with a (very minor) change, I'm setting back to NR.

F) @jweakley Already spent a bunch of time reviewing this from an accessibility angle, so I'm removing the tag. This has had an accessibility review. The fix here is way more accessible than what we have in core right now.

Thanks,
-Derek

Manuel Garcia’s picture

Status: Needs review » Reviewed & tested by the community

Makes sense to me, and code looks good. Only found this nit, which can be fixed on commit or ignored.

+++ b/core/modules/views_ui/tests/src/Functional/FilterNumericWebTest.php
@@ -113,11 +113,34 @@ public function testFilterNumericUI() {
+    $this->drupalPostForm(NULL, $edit, t('Apply'));
+    $this->drupalPostForm('admin/structure/views/view/test_view', [], t('Save'));
...
+    $this->drupalPostForm(NULL, [], t('Update preview'));

To my knowledge there is no need to use t() in tests, unless we're testing translations.

dww’s picture

Re: #131: Thanks for the review! Re: nit -- that entire test is full of t().

A) Out of scope to fix it all here.
B) Seems better to remain consistent with the rest of the test than to only "fix" the parts of that test that are in scope for this bug fix.
C) We should either find (proving difficult) or open an issue about removing t() from tests that don't need them.

Thanks again,
-Derek

dww’s picture

Re: #132.C: According to @longwave, that should be a child of #3113904: [META] Replace t() calls inside of classes ...

$ find core -type f -iname '*test*' | xargs grep '[^a-zA-Z]t(' | wc -l
4913

not 100% accurate but there are roughly 5000 instances of this to fix up

dww’s picture

Re: #130.B and Claro. Preemptively opened #3133639: Fix Claro styles for exposed views filters wrapped in fieldsets so no one delays committing this for "Needs follow-up". ;)

Manuel Garcia’s picture

RE #32 ah ok, yup, I agree on keeping the file consistent.
And yes we definitely should clean that up... if only to have core lead with the best practice. I've opened #3133726: [meta] Remove usage of t() in tests not testing translation for this.

benjifisher’s picture

We discussed this issue at the #3133883: Drupal Usability Meeting 2020-05-12.

There was some concern about how this will affect Claro, since Claro already puts all the exposed filters in a fieldset and nested fieldsets may not be the best solution. We agreed that any problems should be addressed in Claro instead of holding up this issue. I was planning to add a follow-up issue, but I see that was already done in #134. Thanks for that. And the issue already has secreenshots. @dww++.

Aside (numerology)

Since I use a Yellow Pig as my avatar, I have to comment when my favorite number, 17, come up. In #133 I see 4913, which is the cube of 17 and also the sum of its digits is 17.

larowlan’s picture

Lendude’s picture

@larowlan pinged me on slack for my opinion about the BC implications, so my 2 cents....

I feel we are in the clear here from a strict BC policy stand point, per https://www.drupal.org/core/d8-frontend-bc-policy :

# Render arrays (including form arrays)
While the Render and Form APIs themselves are stable, the exposed data structures used to build and cache pages and forms are not. We will change these structures where necessary to make usability improvements or add features in minor versions. This means alter hook implementations may need to be updated.

But from personal experience, Views exposed filters tend to get altered a lot more than most other render arrays, so I do share @larowlan's concern about BC here.

I like the idea of trying to do some sort of BC layer for render arrays, but personally don't feel we should hold anything up waiting for that, the policy as it stands seems pretty clear.

larowlan’s picture

Version: 8.9.x-dev » 9.1.x-dev
Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs release note

Thanks @Lendude
So on that basis I think we have consensus that we're going to need to do this, and the earlier the better. But we're also going to need to communicate the change here in a release-note snippet, as this is something people are going to be aware of in updating.

Can we get a release-note snippet added to the issue summary? Setting to NR for that. Please return to RTBC when added.

dww’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs release note

Added a draft release note.

benjifisher’s picture

Issue summary: View changes

I did a little copy editing of the release-note snippet. We are allowed more than one paragraph, aren't we? I am not sure I chose the best place to break the paragraphs. Maybe we should make it three paragraphs.

dww’s picture

Thanks for the edits, @benjifisher, those look great to me. The guidelines say to be succinct, so I wouldn't expand it into 3 paragraphs if we can help it. If we need to say anything else, IMHO it should go into the CR, not this note.

Cheers,
-Derek

benjifisher’s picture

I was thinking of adding more linebreaks, not more words.

larowlan’s picture

Issue tags: +9.1.0 release notes
larowlan’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/views/src/Plugin/views/filter/NumericFilter.php
@@ -277,17 +277,16 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
-        '#title' => !$exposed ? $this->t('Min') : $this->exposedInfo()['label'],
+        '#title' => $this->t('Min'),
...
-        '#description' => !$exposed ? '' : $this->exposedInfo()['description'],

So we lose the ability to configure the label for a min, and a description - is that intentional?
This was flagged in #71 but I don't see it addressed.

#78 mentions that #76 addressed #71 but I don't see that in the interdiff at #76

Thinking some more about the disruption here - could we make this new behaviour opt-in via a state or configuration flag?

We could default it to TRUE for new sites, but make it an explicit decision for existing sites so that the act of enabling it could be accompanied by an audit of their existing views exposed forms, alter hooks and theme templates?

larowlan’s picture

There is some precedence for making this opt-in, views.settings.ui.exposed_filter_any_label has options 'old any' and 'new any'

So we could add a config option to make it opt-in.

dww’s picture

Re: #145 / #71:

1.

Are we sure about losing the ability to customise this?

The current behavior is IMHO incredibly weird with Between + Min/Max. We use the main (configurable) filter label for "Min", and force "And" as the label for Max (!?!). The operator always says "Operator", even though that's the first element you encounter. If you have multiple numeric/date filters exposed on the same form, it's even more WTFy. This is part of why this is a major accessibility bug (not to mention a major sighted-UI WTF).

We're not losing the ability to customize the filter label. Instead, we now *always* see it (huge win) and it's the label for the entire fieldset. That way everyone, sighted or not, can tell "all these elements belong to a filter called "Whatever you customized it to be". Then it's clear what "Operator", "Min" and "Max" (all hard-coded, unless we proceed with #3120627: [PP-1] Make views exposed filter operator labels configurable after this is done), are all referring to, and we never have a form element labeled "And".

2.

This label is set up above - $edit['options[expose][label]'] = 'Age between'; what happens to it now?

The filter label is now the fieldset legend:

+    $this->assertSession()->elementTextContains('css', 'fieldset#edit-age-wrapper', 'Age between');

Probably that assertion should be more specific so we know we're finding the label in the fieldset legend. Attached patch does so and the test passes locally.

To answer both questions with some pictures:

Before

Single exposed numeric/date filter

Exposed date filter with 'Between' operator, before patch (current Drupal core)

Two exposed numeric/date filters

Screenshot of 2 exposed date filters with 'Between' operators, before patch (current Drupal core)

After

Screenshot of a view with 2 exposed filters that expose an operator, with both patch #3120627-45 and #2625136-129 applied, once one filter uses 'between' for the operator.

Re: #145:

could we make this new behaviour opt-in via a state or configuration flag?

If we have to, I guess we could. As I wrote at #119, I truly don't like that idea:

I'd be really sad to have to write a BC layer, an opt-in new setting to get a working UI, an upgrade path to set existing sites to "use-broken-UI-for-exposed-forms = TRUE", and upgrade tests, all so that folks that already fixed this bug don't have to let core fix it for them for real.

Looking again at those before screenshots, I can't fathom why anyone wants/needs that behavior. Even if we jump through all these hoops for a "use the legacy broken filter UI", I don't think this is going to be considered patch-eligible, so why bother? Can't we just have a clean, minor-only fix, without technical debt and hassles, make folks stop working around this totally broken UI and let core fix it for them?

catch’s picture

If we do this minor only with a change record, then it's possible that contrib or custom code altering the form array might break - however that's an allowable change in a minor release (especially to fix a bug).

If we add a bc layer:

1. If it defaults to 'on', then sites without the alters also won't get the bug fix unless they know where to find and disable the bc layer.

2. If it defaults to 'off', then all the sites that would have broken due to alters will still break, they'll just have the option to switch the bc layer on

3. Any contrib code altering the render array will still need to be updated for both the 'on' and 'off' case, but instead of only needing to support both cases until 9.0/8.9 is out of support, they'll need to support them until Drupal 10 when we remove the bc layer.

edited to add:
There's also a third option of delaying the bugfix until Drupal 10 - where we can unapologetically break bc. However, this would introduce an inconsistency between 9.LTS.x and 10.0.x, whereas we tried to keep 8.9 and 9.0 as similar as possible with the exception of major-only changes. Also contrib would have to support both versions for longer.

rgpublic’s picture

IMHO, 9.x is still so fresh that the BC layer would really be a bit over-the-top. If you are currently creating sites with 9.x, fact is that you probably run into all sorts of minor problems. In a real-life world, you also use contributed modules, some of them even need patches for D9, you have minor glitches literally everywhere. At least that's what I'm currently experiencing, building *actual* D9 sites.

Some form_alter hook not working anymore due to some changing elements is sth. you encounter all the time in Drupal one way or another - it's a rather easy problem to solve for someone who is using form_alter hooks in the first place. There is *much* worse that can happen to your site. I think it should be sufficient to just change it and publish a change record.

benjifisher’s picture

+1 for doing this in 9.1.0 with a CR and no BC layer. See the first paragraph of #148.

dww’s picture

Great, that's 3 votes in a row for committing #147 as-is, without technical debt. Anyone willing to RTBC this? 😉 🤞

Thanks!
-Derek

jibran’s picture

Status: Needs review » Reviewed & tested by the community

We are already using three patch combo so this is ready in my books. Thanks, for all the work on this @dww.

larowlan’s picture

Saving issue credits

  • larowlan committed 9fdb203 on 9.1.x
    Issue #2625136 by heddn, dww, kevin.dutra, sukanya.ramakrishnan, finne,...
larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Ok, on the basis of discussion above and comments from @catch - Committed 9fdb203 and pushed to 9.1.x. Thanks!

Our approach here is as follows:

- document the change in the release notes
- change notice

This is a tricky one, so I think doing it now rather than later in the 9.1 cycle maximizes our chances of finding issues.

Published the change record and decremented the PP count on the postponed issue.

This obviously won't be backported, for disruption reasons.

larowlan’s picture

Issue tags: +Bug Smash Initiative

Tagging for bug-smash, as this was one of our goals for the fortnight

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

shelane’s picture

This "fix" has introduced some strange behaviors. I have not been able to find out how to "undo" it with hook_form_alter. It's a fight between the theme that is now rendering the fieldset in a specific way that I undo without affecting everyplace a fieldset is used.

sergei_semipiadniy’s picture

@shelane Same problem.
Fixed by creating own views filter plugin and overriding parent's buildExposedForm method.
There you just remove annoying wrapper.

shelane’s picture

I used form alter to change the fieldset to a container. Then it didn’t have the styles applied to it.

quietone credited Dom..

quietone credited hkirsman.

quietone credited mtnguru.

quietone credited Pancho.

quietone credited steamx.

quietone credited yoroy.

quietone’s picture