Problem/Motivation
For accessibility, some tables call for having both column headers and row headers. The WAI table concepts tutorial describes a number of table models, with corresponding example use cases.
The tables currently generated by views are all tables with one header. These are quite acceptable for many cases, including many of the administrative views in Drupal core.
This feature request aims to support simple tables with two headers, with accessible markup. Such tables have <th scope="col"> in the <thead>, and a <th scope="row"> as a header inside each <tr> row, as appropriate. This is primarily intended as a feature for site builders, though future administration tables provided by by core or contrib modules may also benefit from it.
Recently #1831162: Tables generated by Views need better semantics. added the scope="col" for column header elements, but did not add any support for row headers.
Proposed resolution
A configuration option that allows the site builder to set any column in a table to be treated as a table header for that row. The site builder will also have the option not to have any row header, producing only column headers. Note that this approach is flexible enough to support tables with an offset column of header cells.
Note: supporting tables with irregular headers or tables with multi-level headers is NOT in scope for this issue. If #893530: Multi level (multirow) header for table FAPI element gets into core, we can create separate feature request issues for these.
Table format settings showing new Row Header column. Title field has been selected:

Content list view output with title field selected as the row header (Seven Theme):

Note: the column header styles apply to the row header field on hover (see comment #21)
Content list view output with title field selected as the row header (Bartik Theme):

Selecting a field as the row header causes that field to be rendered as a <th> tag inside the table row:

Remaining tasks
- DONE. Usability review: do we use a column of radio buttons or a drop-down select? See comment #33, @yoroy has a preference for a column of radio buttons, but it doesn't seem like a strong preference either way.
- DONE. Add a setting to the Views table display plugin config form.
- DONE. Update markup in output.
- DONE. Review design impact for Bartik, styling of row-headers. See comments #22 and #33, @yoroy is happy.
- DONE. Review design impact for Seven, styling of row-headers. See comments #21 and #33, @yoroy's comment could do with clarifying. This change also impacts other themes that ship with core; Bartik, Seven, Classy, Olivero, Claro
- DONE. Write tests. Rough plan outlined in comment #65. @lendude added tests in #65 and subsequent rerolls adopted this test.
- TODO: Update existing views which use the table display plugin, to include the new config option (set to none). See comment #67.
- DONE: A change record with advice for themers:
- If they already have a custom
views.view-table.html.twigtemplate, it will need updated to benefit from this feature. - Turning on the new row-level headers option may have an unexpected effect on how tables look, if their theme doesn't already anticipate row-level table headers.
- If they already have a custom
User interface changes
- An additional configuration in the views style format. Either of these:
- An extra column of radio buttons in the settings table, similar to the default-sort column (screenshot in comment #16)
- A drop-down select, which has a description (screenshot in comment #30)
- (Possibly) a different appearance for table headers on each row (if design review permits it).
We do not propose to change the configuration of any existing admin views tables in core as yet.
API changes
None.
Data model changes
Additional "row header" option in Views table display config, similar to the existing default-sort option.
Original report by @gettysburger
Accessible tables have "scope=col" in the headers and "scope=row" in the first field in a row. The first field in the row should also have a <th> instead of a <td> tag. Tables generated by Views have scope=col" but not scope ="row". A recent issue (https://www.drupal.org/node/1831162) added the "scope=col" but did not add "scope=row".
I proposed that "scope=row" be added to the first field in each table row and that first field in the row should also have a <th> instead of a <td> tag.
| Comment | File | Size | Author |
|---|---|---|---|
| #134 | interdiff_133_134.txt | 774 bytes | carlygerard |
| #134 | 2770835-134.patch | 14.6 KB | carlygerard |
| #133 | interdiff_127-133.txt | 6.31 KB | carlygerard |
| #133 | 2770835-133.patch | 14.62 KB | carlygerard |
| #132 | interdiff_127-132.txt | 3.61 KB | carlygerard |
Issue fork drupal-2770835
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
gettysburger commentedComment #3
gettysburger commentedComment #4
gettysburger commentedComment #5
mgiffordComment #6
andrewmacpherson commentedtidying up the issue summary
Comment #7
dawehner\template_preprocess_views_view_tablewould be probably the right place to add it.Comment #8
andrewmacpherson commentedThe tables currently generated by views are all tables with one header.
This isn't really a bug in my view, in that I don't think we should force authors to use a two-header table model. Looking though the WAI table concepts tutorial, it's clear that tables with one header are quite acceptable for many cases, including many of the administrative views in Drupal core.
Instead, let's treat this as a feature request. It would be really great if views could support some of the other table concepts described there!
I think it's feasible to support simple tables with two headers. The table display plugin could have an extra setting to say that a particular field is treated as a row header, and
scope="row"could be added via thecolumn.attributestwig variable (I think). This would be flexible enough to support tables with an offset column of header cells. I'm not sure what to do about the top-left cell, which might need to be blank.Support for some tables with irregular headers might be possible, perhaps using views query grouping, but would add more configuration options. This might be best explored as a separate views display plugin provided by a contrib module.
Comment #10
mgiffordFirst, I'd like to agree what Andrew said & disagree with this "Accessible tables have scope="col" in the headers and scope="row" in the first field in a row." It all depends on the table and the data you are trying to display. Right now you can't define the scope="row" which is a problem if have a heading there you want to use.
I'm fine with looking ahead at how to make the Views tables more complex. There is a lot of tabular data that I don't think we can very effectively show right now.
Right now we generally have the first row being headings and all the other cells being data cells. I don't know of an instance where the first field in each table row is actually a heading.
Sometimes it is a checkbox. I guess if it is a first name or title of an article that could be considered a heading.
There are great examples of accessible table structures here https://www.w3.org/WAI/tutorials/tables/
I just don't know how we would get to two meaningful headers in Views table display so that it reflects the needs of https://www.w3.org/WAI/tutorials/tables/two-headers/
Comment #11
miwayha commentedI don't see where gettysburger uploaded a patch for this on 8.
I created a sandbox project for this issue on 7: Views Table Row Headers. I'm reasonably experienced site builder, but I'm very new to drupal development. If someone would be willing to mentor me either through releasing this as a module and porting it to 8 or making the change to core in 8, I would be very grateful.
Comment #12
miwayha commentedAttempting a patch for d8.
Comment #13
miwayha commentedCleaned up issue summary.
Comment #14
mgiffordCan I configure this through Views UI? Trying to understand what the current code does and how to see it in action.
Comment #15
miwayha commentedYes! View the format settings after setting format to "table". There should be an added column of radio buttons with the heading "row header" in the table that has the field config.
Comment #16
miwayha commentedUploading screen shot of new interface...
Comment #17
andrewmacpherson commentedThanks @miwayha - this is very exciting progress! I'll review it more closely soon.
Comment #18
andrewmacpherson commentedThe new radio buttons for row header follows the same pattern as the default-sort configuration.
It has a "none" option which is great - it means a site builder can change their mind and go back to a single-header table if they wish. (In fact I did so several times, just to get some screenshots...)
Comment #19
andrewmacpherson commentedThe markup is what we expect. I modified the core /admin/content view so that the node "Title" is treated as a row header. Here's a screenshot of the markup:
The cell for the node title is a
thelement with ascope="row"attribute.Comment #20
andrewmacpherson commentedUpdating issue summary to reflect the new plan as a feature request:
Comment #21
andrewmacpherson commentedIn the Seven theme, using the patch from #12, row headers inherit some different styling similar to the column headers.
For these screenshots I modified the core
admin/contentlisting to output the node title as a row header. The mouse pointer is not incliuded in the screenshots, but they show the hover style on the second row.Before patch #12, just column header:

After patch #12, treating node title as a row header:

We'll need design review for this, tagging for Seven maintainer too.
Comment #22
andrewmacpherson commentedFor completeness, here is how row headers look in Bartik.
Like the previous screenshot for Seven theme, this shows the
admin/contentlisting, modified so node title is a row header. Then I set Bartik as the admin theme.I like this, it's very clear, and matches the column headers perfectly.
Nonetheless, it needs design review sign-off. Tagging for Bartik maintainer.
Comment #23
andrewmacpherson commentedNote: these screenshots also demonstrate that the proposed solution is flexible enough to support tables with an offset column of header cells.
I am very excited about this new feature!
Comment #24
andrewmacpherson commentedComment #25
andrewmacpherson commentedWe still need a code review of the patch from #12
Comment #26
dawehnerI'm wondering whether we should move "row header" further to the right on the views admin screen. It seems to be for me that "sortable" might be more often changed for example. IMHO we need some better way to communicate what this feature does to the user.
Comment #27
andrewmacpherson commentedWe could take the row-header options out of the table, and present them as a drop-down select, the way the grouping option is shown. Then it could have a #description of its own, which the options in the table don't have.
Comment #28
dawehnerThat might be indeed a good idea. Let's see whether someone from the UX team can help us with that.
Comment #29
miwayha commentedMy sandbox module for D7 uses a dropdown select, if you'd like to test with that rather than coding something from scratch.
Comment #30
andrewmacpherson commentedHere's a screenshot from @miwayha's D7 sandbox module.
It shows a drop-down select for choosing the row header field, as described in #27.
If we choose this rather than radio buttons in the table, we'll need to decide what weight to give it in relation to the other settings.
Comment #31
andrewmacpherson commentedFor the usability review, we're comparing two ideas for the setting widget:
For the design review, we're looking at the screenshot in comments #21-22.
Comment #32
andrewmacpherson commentedUpdating tasks
Comment #33
yoroy commentedA select list on a separate config modal is less clear than the column of radio buttons on the table itself. But the config modal gives us a little more room to explain the feature. Could we maybe make the "None" option explain what this is all about?
I think I prefer the radio buttons on the table. But: it's another column. Could we add a setting on the config modal to enable multiple header selection in the first place?
I think Bartik looks fine. I'm not the maintainer, but I think this is what it should be.
For Seven we should apply the same styling as is used along the top.
Comment #34
andrewmacpherson commentedComment #35
scuba_flyI'm looking into this at the DrupalCon Dublin 2016
Comment #36
miwayha commentedExcited to see what comes of this in Dublin. I'll keep an eye on this issue, and I'll be happy to contribute any other patches to it if need be.
Thanks so much for doing a ton of work on this, @andrewmacpherson and others!
Comment #37
scuba_flyI talked to yoroy and moving the column more to the right should be enough for now.
In the future it would be nice to be able to hide elements in the form because it gets a little full in the table.
I'll add a interdiff in a moment.
Comment #39
scuba_flywhoops made the patch from the wrong directory.
Here is a new patch with the core path included.
Comment #40
scuba_flyComment #41
manuel garcia commentedJust reworking a bit an if/else block so its easier to follow
Comment #42
miwayha commentedComment #43
Bojhan commentedNot sure what to review, yoroy already looked at this.
Comment #45
delacosta456 commentedhi
it would have been nice if somebody could help us please with a patch for irregular headers in D7..
thanks
Comment #46
manuel garcia commentedPatch not applying anymore, rerolling
Comment #47
manuel garcia commentedHad to manually fix these two files:
Conflicts were due to the switch to short array syntax in core, so rerolled appropriately.
Comment #50
ivan berezhnov commentedComment #52
john.lee.doe commentedfor my project , it is great full.
Comment #53
manuel garcia commentedJust a patch cleanup:
No reason to move this method around that I know of, so undoing this from this patch to make it easier to review.
Comment #54
john.lee.doe commentedHow to integrate with multi level header rows in this view table.
Comment #55
andrewmacpherson commentedre: #54 - that's out of scope for this issue, but it's already mentioned in the issue summary as an idea for future work.
Thanks for mentioning the #893530: Multi level (multirow) header for table FAPI element here, though. I've linked to it in the issue summary here.
For views to produce multi-level headers, I think we'll have to wait until #893530: Multi level (multirow) header for table FAPI element is done first. Then we can open up a new issue to look at ways of letting a site-builder produce them with Views. Maybe we can extend the existing table views display in core, or it might need a separate views display plugin.
Comment #56
themusician commentedThe patch as re-rolled applies cleanly. The formatting appears to check out as well.
In this image you can see the new table setting appears when editing a table view. This is a clone of the watchdog view.
Then, the
Comment #57
star-szrSorry just drive-by Twig standards stuff for now.
Are the parens needed?
In both these cases, there should be no space before we print the attributes.
Comment #58
themusician commentedThanks for the quick look @cottser.
It seems like the parenthes are not needed. It seems to work properly at least without them.
The spaces are removed prior to the attributes being printed.
Interdiff also attached.
Comment #59
themusician commentedComment #60
andrewmacpherson commented@theMusician - thanks for working on this.
Review of patch #58:
Unnecessary whitespace changes. I tested with Stark, and it has no effect on the output. I checked our Twig coding standards about this - there's no explicit opinion, but the examples don't have whitespace between element name and curly brace.
Same as previous point.
Comment #61
andrewmacpherson commentedWe'll need functional tests to check the output of the new option.
Comment #62
andrewmacpherson commented@cottser - Where do we stand with Stable and Classy themes here? We're adding a new UI option which won't work unless they have the right template. The current patch changes templates in Views module and Classy theme, but what about sites using
base theme: falseand have the Stable template?I think there's low risk to existing websites, because they won't have row-level headers configured for table views. Until a site-builder makes use of the new option, the output will be unaffected.
TODO:
views.view-table.html.twigtemplate, it will need updated to benefit from this feature.Comment #63
themusician commentedI reviewed the twig coding standards as well and agree, nothing is explicit but the samples do not have a space.
Attached is a patch that includes the update to the standard view twig template as well.
Comment #64
themusician commentedRegarding tests, as views has a lot of them. Where would one start?
It seems that any test file that includes an option for "sortable" would need to have "row_header" added as well.
From there, what other test files need to either be edited or created?
This doc helps for a simple module, https://www.drupal.org/docs/8/phpunit/phpunit-browser-test-tutorial, but the amount of tests in views has me a little perplexed.
Comment #65
andrewmacpherson commentedCan we get a 58-63 interdiff?
This one is really close, tests are the last part needed.
@theMusician - this is probably going to be functional tests rather than unit tests. Look at tests inside
core/modules/views/tests/src/Functional/to find some. They typically make use of a test module insidetests/src/modules, and the test modules will have installation config like any other module. In views case, theviews_test_configmodule has lots of specimen views.Maybe we can add an extra test method to
core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php. The test process will be something like:<th scope="row">is there for the chosen column,<tr>for the other columns,Also assert a table display with row-level headers configured as "none" does not have an TH inside the table body.
Comment #66
themusician commentedThanks @andrewmacpherson for the guidance on the tests.
The interdiff is attached. Interdiff 58-63
If anyone is sprinting at DrupalCon and wants to tackle the tests please dive in!
Comment #67
lendudeSince we adding a new option we should really have an upgrade path for this to add the option to existing views. One problem with adding new settings to the table style is that existing settings are probably not up to date anyway, see #2917814: Views table style info never gets updated when changing/adding fields
Comment #68
lendudeNitpicks:
This could be a more complete sentence explaining what's going on and why, and is there an open issue for that?
"We need to set the id using attributes because 'radio' doesn't fully support #id."
Missing a trailing period.
old skool array() notation needs to be []
> 80 characters
> 80 characters
Comment #69
andrewmacpherson commented@lendude
Thanks for the related issue. DO you think it'll be a blocker for this one? I mentioned the upgrade path in #62, but didn't update the issue summary. I'll do that now.
I've reviewed the comments going all the way back, and updated the tasks in the issue summary to says what's been done.
One thing that isn't quite clear: are we happy about how row-level headers look in Seven? There's a screensnot in #21.
Later in #33 @yoroy says "For Seven we should apply the same styling as is used along the top", but I don't think we've acted on this. I think it means the row-level headers should get the beige background colour. I also think the link underlines look odd, in the screenshot example which made the node title links as the row headers.
Let's seek a design review again for Seven.
Comment #70
andrewmacpherson commentedLet's get some screenshots set up using the latest patch, and add them to the issue summary.
Here's a good novice task for the Nashville sprints...
admin/contentlisting, make the node title field act as a row-level table header.admin/content. Make sure the mouse pointer is hovering over a node title, we want to confirm if the broad link underline from screenshot #21 is still an issue.admin/content, mouse over a node title.Bonus level: find a member of the usability or design team, or a product manager, and get an opinion how it looks in Seven to clarify comment #33.
Comment #71
amkloseI'll work on getting those screenshots (here at Drupalcon Nashville)
Comment #72
lendude@andrewmacpherson probably not since we'd only add a setting that is not tied to the fields that exist on the view (well the default setting isn't anyway...), so I think we can workaround this.
Addressed my own nits.
Added the needed config schema changes and the most minimal of tests. If anybody wants to turn this into a proper test, go for it!
Comment #73
amkloseAdded some screenshots to the proposed resolution section of the issue summary. I verified that the styling pointed out in #21 still applies for Seven and Bartik.
Comment #74
amkloseRegarding the bonus level task in #70, I spoke with Benji Fisher and dug into the CSS a little bit. It looks like the
<th>tag background styles are specific to the<thead>section in the Seven theme, but the link underline style is not that specific. I changed the CSS selector in my browser inspector so that the gray background was applied to all<th>elements but Benji and I agreed that this looked a little strange. See the following screenshot.With Hover:
By making the styles more generic, it includes the following CSS on all
<th>elements:We also wondered whether that change might be out of scope for this issue since it would require a css change to the Seven theme.
Comment #75
lendudeSomething I noticed wile writing tests for this, when the view has no results the empty result area gets turned into a th while the setting is set to 'none'. That doesn't sound like the desired behaviour.
Comment #76
themusician commented@Lendude, thanks for outlining what the tests would look like. For anyone wanting to wrap up tests take a look at drupal/core/modules/views/tests/src/Functional/Plugin/StyleTableTest.php starting on line 250 once the most recent patch has been applied.
In regards to no results returning from a table styled view, I cannot recreate that occurrence.
It seems a no results default for views in table format is to simply not display anything at all. I cannot get an empty table to render if there are results.
Comment #77
lendude@theMusician it was the 'empty message' that got set to a
<th>, but I can't reproduce it anymore, no idea how I got it that state, but thanks for checking!Comment #78
rakesh.gectcrAdding tag for the sprint
Comment #79
andrewmacpherson commented@rakesh.gectcr - I'm attending the NWDUG sprint too. The remaining work here is to finsih the tests, and it would be good to look at the core theme styles more closely.
Comment #80
andrewmacpherson commentedThe novice tasks in #70 were done, not currently needed.
Comment #81
andrewmacpherson commentedGathering some issues up into a bigger-picture plan for improving tables.
Comment #87
themusician commentedRerolled the patch from #72.
Comment #88
themusician commentedTrying a new editor and apparently my formatter is not firing on save. Another attempt.
Comment #89
themusician commentedOk. I think I finally have PHP code sniffer configured properly with Lando.
Attempt at the re-roll #3.
Comment #90
themusician commentedAnd one more fix with functions needing comments.
Comment #91
carlygerardTesting out the patch in #90, I could get the template to print correctly in the view, with a
<th scope="row">,if I didn't include the fixes with the views_ui.theme.inc.Adding in the changes from the views_ui.theme.inc file caused the row header settings to no longer apply correctly. But, without adding the views_ui.theme.inc changes, the table settings is no longer usable:
Wondering if anyone else is running into this applying the patch from #90, or if it's just something I'm doing.
Comment #94
carlygerardPatch includes Olivero and Bartik view table templates, with row scope support. This still uses tests written by @lendude referenced in #75.
Comment #95
carlygerardCleaning up PHP files through phpcbf based on previous test results.
Comment #96
ranjith_kumar_k_u commentedRe-rolled #95 for 9.4.
Comment #97
ranjith_kumar_k_u commentedComment #98
carlygerardIncluding Umami views-view-table twig file to fix classy copy error. (Duplicate patch error--previewing comments made it seem the file was removed, had re-added just in case.)
Comment #99
vikashsoni commentedApplied patch #96 in drupal-9.3.x-dev applied successfully
After patch row header has been added
Thanks for the patch
for ref sharing screenshot ...
Comment #100
themusician commentedThis patch updates the hash for the file views-view-table.html.twig which appears to have been causing the failed tests. This works locally running the test ConfirmClassyCopiesTest.php --filter=testClassyHashes with phpUnit.
Comment #101
carlygerardUpdates classy view table templates in Claro and Seven to fix test results in #100.
Comment #102
themusician commentedThe patch in #101 works for 9.4.x and prior recent rerolls work for earlier Drupal installs.
The issue summary has been updated to reflect where I believe this issue now stands.
In the remaining tasks, there exists
In reviewing that comment I am unsure if this is truly a blocker for improving the accessibility options available in Drupal views.
Change record coming for review.
Comment #103
themusician commentedPlease review the change record at https://www.drupal.org/node/3263530.
Primarily this was based on the prior recommendations and the work discovered while crafting the patches with everyone on this issue.
Comment #105
carlygerardInterdiff between failing 9.3.x #95 and passing #101 for 9.4.x. Patch couldn't apply to 9.3.x because of conflicting comment.
Comment #106
carlygerardRefactored #104 patch to cleanly apply to 9.3.x.
Comment #107
carlygerardReroll #106 to add stable and starter-kit view templates.
Comment #108
carlygerardReroll #101 to add stable and starter-kit view templates for 9.4.x.
Comment #109
carlygerardReroll #107 to pass php formatting tests in 9.3.x.
Comment #110
wrd-oaitsd commented#109 is working nicely for me.
Comment #111
themusician commentedComment #112
lendudePlease don't add unrelated coding standards changes to these patches. It makes them bigger and so much harder to review because we now need to think about if a change is needed.
Setting back to needs work to limit this to the changes that are actually needed for this feature.
Comment #113
themusician commentedThank you for the feedback.
Can you help me understand what is unrelated? In 9.4.x it seems like there are a lot of views-view-table twig files in Drupal core. Without including those files, the tests fail to pass I believe due to /Core/Theme/ConfirmClassyCopiesTest.php. As I understand it, if Bartik for example has a copy of the views-view-table twig file and it is not updated, the accessibility improvement in this patch would be ignored because that would override the template default.
Beyond updating those files and the hash to make the tests pass 9.x I am not sure what else is not related.
If those files do not need to be updated, what is the trick for making the tests ignore them?
More than happy to do the work, I just don't know what I don't know.
Comment #115
andregp commented@Lendude, Here I tried to remove all CS corrections that weren't necessary for the patch.
Comment #116
charchil khandelwal commentedComment #117
charchil khandelwal commentedPatch # 115 tested and applied successfully in drupal 9.5.x version.
Comment #118
alexpottI think we need to target 10.1.x for this feature request as we're in beta for 9.5.x so it's closed to new features. Plus the patch doesn't apply to 10.1.x so we need to 10.x version anyway.
Can't we assert on the actual content. Or something a bit more positive. Also shouldn't we be selecting on
scope="row"Plus we have no test coverage that the UI actually works.
Comment #119
themusician commentedThis doesn't get us a UI test coverage fix but I believe this is now applying cleanly to 10.1.x-dev.
The original patch from 9.5.x trying to apply to 10.1.x-dev.
This makes sense as those files have been removed from 10.1.
Attached is a new patch and a diff of the reroll showing the files being removed from the new patch.
Comment #121
mgiffordThis fits under WCAG SC 1.1.1.
Comment #122
pooja saraah commentedFixed failed commands on #120
Attached patch against Drupal 10.1.x
Comment #123
themusician commentedComment #124
lendudeStill needs test coverage for the Views UI working.
This is still too minimal, we should actually check what is in it
I don't think we can change these here templates since they are 'stable'
And looking at this again, we should add an upgrade path to set the default value for existing Views so people don't get unrelated changes later when they change a View
Comment #125
themusician commentedThank you for the feedback Lendude. Items 1 and 2 I believe I have knowledge of how to address moving forward.
Regarding an upgrade path for existing views, in the proposed patch this is set in Views/Style/Table.php,
$options['row_header'] = ['default' => ' '];For existing views, where would I look to provide an upgrade path? In local testing, existing views seem to show the new row header option but not have it selected. I am guessing I am missing something obvious.
I appreciate any guidance you can offer.
Thank you
Comment #126
themusician commentedA new patch that does a more robust check for scope=row on output.
Removal of changes to stable9.
Thank you @CarlyGerard and @packern for team programming on this patch.
Comment #127
themusician commentedMissed the code formatting fixes. Trying again.
Comment #128
themusician commentedI believe the new patch satisfies the concerns raised earlier in the discussion.
Comment #129
smustgrave commentedCleaned up the tags some.
Seems #124 still needs to be addressed.
For the upgrade path it will, I believe,
1. need to load all views
2. Check if they are using table
3. Add this setting even if it's unchecked
Idea being if this patch is applied and I open a view with a table. If I make 0 changes and click save and configuration is shown as changed because of this new setting then that would need upgrade path.
Upgrade test can be simple
Check a view table that this setting doesn't exist
Run updates
Check setting now exists.
Comment #131
carlygerardAdds upgrade path test to views where if not set, set header to "none." The interdiff showed a template also removed a classy template--I think in 11.x-dev the classy files are removed, unless someone can confirm otherwise?
Comment #132
carlygerardRe-rolled patch from comment #131 since it couldn't apply.
Comment #133
carlygerardFixing custom commands error from ViewsConfigUpdater.php in #132, where the bool value wasn't returned properly given the function parameter.
Comment #134
carlygerardFixes undefined array key issue flagged from ViewsConfigUpdater.php in last CI testing.
Comment #135
themusician commentedHooray. Passing tests again and they are more comprehensive. I believe this checks all the tests described in comment #129.
Comment #136
themusician commentedThe change record has been updated to reflect the current passing patch.
https://www.drupal.org/node/3263530
Comment #137
lendudeThis should follow the pattern of 'needsABC' and further changes to ConfigEntityUpdater so it will also update newly imported config when installing a module like we do in other Views updates.
Also we need a test for the upgrade path to make sure it actually works
Comment #138
themusician commentedAs always, thank you for the feedback and guidance.
On my dev instance, there is an upgrade test in theory that operates but I can't get views actually to run an update hook.
A new file in tests/fixtures/update exists called set_row_header_option.php
It looks like
and then in tests/src/Functional/Update/ViewsSetRowHeaderUpdateTest.php I try to run the test which includes firing the updates using runUpdates(); which as I understand it runs update hooks. It is modeled after ViewsFixRevisionUpdateTest.php in the same directory.
which I think means the update hook needs to be in views.install. I have tried various iterations but when runUpdates() executes it doesn't apply any changes. Is there a different spot that updates go to when running tests? I can't find any views updates that would correspond to the other tests in /Tests/Src/Functional/Update.
I don't get any errors in the tests except that after running the updates, the new key cannot be found which tells me the hook_update I added into views.install is not running properly. If I introduce a syntax error into the hook_update, the test will fail and point out the syntax error, so it does seem like it wants the code to be in that spot.
Thank you for any hints.
Comment #139
themusician commentedI believe the code for ViewsConfigUpdater needs to be called https://git.drupalcode.org/project/drupal/-/blob/96d21a4603df23080a34051... in updateAll of viewsConfigUpdater for the test runUpdates() function to work.