Skip to content

dl responsive table view#1156

Open
regularfry wants to merge 21 commits intomainfrom
1092-stacked-list-read-order
Open

dl responsive table view#1156
regularfry wants to merge 21 commits intomainfrom
1092-stacked-list-read-order

Conversation

@regularfry
Copy link
Copy Markdown

@regularfry regularfry commented Feb 26, 2025

Description

This patch is an implementation of the markup-swapping fix for #1092 . It introduces a few new elements: since the table uses a caption and we need to preserve that, but caption isn't valid outside a table, the dl implementation uses figure and figcaption to do the same job.

Tested so far on macOS Chrome and Safari, and the VoiceOver/Safari combination.

Also fixes #1123.

Checklist

@regularfry regularfry changed the title WIP Initial implementation of the dl table view Initial implementation of the dl table view Mar 5, 2025
@regularfry regularfry changed the title Initial implementation of the dl table view dl responsive table view Mar 5, 2025
{%- endif %}

{%- if params.responsive %}
<figure class="nhsuk-table__list-view-container">
Copy link
Copy Markdown
Contributor

@colinrotherham colinrotherham Mar 11, 2025

Choose a reason for hiding this comment

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

Because list-view-container isn't a child of nhs-table can we rename this?

Suggested change
<figure class="nhsuk-table__list-view-container">
<figure class="nhsuk-table-list-view-container">

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

nhsuk-table__panel-with-heading-tab and nhsuk-table__heading-tab aren't children of nhsuk-table either. In practice the rule seems to be that the nhsuk-table is the block that implements the primary view, and auxiliary but semantically linked elements share that prefix. I don't think that's unreasonable, because if we were constrained to encoding a hierarchy we'd just chain the classes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, they're overdue a refactor too 😬

Just pointing it out because we follow BEM methodology (and BEM for everyone else)

We have an unused .nhsuk-table-container in the CSS so would be a good opportunity for a reset

.nhsuk-table-container {}
.nhsuk-table-container__panel {}
.nhsuk-table-container__tab {}
// etc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i.e. We have multiple blocks, with a block (container) being a container for another block (table)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, I'm familiar with BEM. I didn't think it required a parent-child relationship, just that the elements aren't used separately. If we're insisting on containment that's fine.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry I should have said child descendant

Yeah we should use this opportunity to go for containment, thanks Alex

{%- if params.responsive %}
<figure class="nhsuk-table__list-view-container">
{%- if params.caption %}
<figcaption class="nhsuk-table__caption--m
Copy link
Copy Markdown
Contributor

@colinrotherham colinrotherham Mar 11, 2025

Choose a reason for hiding this comment

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

Gets a bit wordy though, but preserves ${block}__${element}--${modifier}

See what else works

Edit: It was this comment that has the suggestion that was a bit wordy but I'm not totally sure how to address the nhsuk-table__caption element existing outside of its nhsuk-table block 😔

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This one is specifically to reuse the already-defined style so we don't have to duplicate it. The figcaption doesn't need its own class here.

Copy link
Copy Markdown
Contributor

@colinrotherham colinrotherham Mar 13, 2025

Choose a reason for hiding this comment

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

I know it doesn't need it, but the pattern is to add one

Would be brilliant to refactor and share nhsuk-table__caption styles where possible though

Then we can tap into these:

.nhsuk-table__caption--s
.nhsuk-table__caption--m
.nhsuk-table__caption--l
.nhsuk-table__caption--xl

Sticking with BEM allows us to refactor elements or nesting in future, without breaking changes

But how do we follow the convention when the <figcaption> isn't a child of nhsuk-table?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The fundamental problem here is that nhsuk-table is on the wrong DOM element. There should be a root div to wrap all the related gubbins that goes outside the <table> itself. That's not something I'm particularly keen to pick up as part of this PR though.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I caught up with the team and they're happy for me to help with this?

We've got other breaking changes coming up (e.g. updated header) so would be the perfect opportunity

@colinrotherham
Copy link
Copy Markdown
Contributor

colinrotherham commented Apr 7, 2025

@regularfry I've rebased this to resolve any recent conflicts

I'll be coming back to pick up from this comment soon

@colinrotherham
Copy link
Copy Markdown
Contributor

I've updated the blank cells example to extend the new example.njk layout

Plus missing reference screenshots

@colinrotherham colinrotherham force-pushed the 1092-stacked-list-read-order branch 2 times, most recently from 58adb89 to b6382f2 Compare May 29, 2025 16:12
@colinrotherham colinrotherham force-pushed the 1092-stacked-list-read-order branch from 31093dd to 6e9fe8c Compare June 9, 2025 17:02
@colinrotherham
Copy link
Copy Markdown
Contributor

Rebased again into new packages structure

@colinrotherham colinrotherham force-pushed the 1092-stacked-list-read-order branch from b1db795 to b594883 Compare June 11, 2025 19:13
@colinrotherham colinrotherham force-pushed the 1092-stacked-list-read-order branch from b594883 to dbcc2a6 Compare June 26, 2025 15:40
@anandamaryon1 anandamaryon1 temporarily deployed to nhsuk-frontend-pr-1156 July 17, 2025 11:03 Inactive
@anandamaryon1 anandamaryon1 temporarily deployed to nhsuk-frontend-pr-1156 July 22, 2025 13:19 Inactive
@anandamaryon1 anandamaryon1 temporarily deployed to nhsuk-frontend-pr-1156 July 22, 2025 13:31 Inactive
@anandamaryon1 anandamaryon1 temporarily deployed to nhsuk-frontend-pr-1156 July 22, 2025 14:40 Inactive
@anandamaryon1 anandamaryon1 temporarily deployed to nhsuk-frontend-pr-1156 July 22, 2025 14:45 Inactive
@colinrotherham
Copy link
Copy Markdown
Contributor

I'm going to rebase this PR branch @anandamaryon1 and have a look later if I can 😬

Merges and extra commits

@colinrotherham colinrotherham force-pushed the 1092-stacked-list-read-order branch from fbaaabd to 0df0524 Compare September 2, 2025 09:52
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Sep 2, 2025

@colinrotherham colinrotherham temporarily deployed to nhsuk-frontend-pr-1156 December 2, 2025 18:05 Inactive
@anandamaryon1 anandamaryon1 modified the milestone: v11.0.0 Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove redundant roles on the Table component?

3 participants