thepensionsregulator / govuk-frontend-aspnetcore-extensions

Adds client-side validation, additional components and editing in Umbraco to https://github.com/gunndabad/govuk-frontend-aspnetcore
MIT License
16 stars 1 forks source link

If you apply row classes to adjacent blocks, all but the last one are incorrectly discarded #340

Closed sussexrick closed 1 month ago

sussexrick commented 1 month ago

We have always combined grid rows where possible as they interfere with margin collapsing and affect the spacing between components. This is a good thing.

However, when an editor applies a class to a grid row, they take responsibility for the styling of that grid row and they expect the class to be applied. This happens if the class is different from that applied to the previous and next blocks, but if they're the same then the rows are combined and the class applied to the combined row.

A use case which shows this is undesirable is adding the .govuk-grid-row--tpr-divider class to several adjacent blocks. You would expect it to add a line below each block, but the rows are combined and the line only appears after the last block.

The PR changes the logic to consider that applying a class is a reason not to combine rows, even if that class is the same as the previous or next one. The changed logic is only in BlockList.cshtml and BlockGrid.cshtml. The other changes are simply replacing hard-coded strings with C# constants.

Fixes #339.