Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better control of the order of items on the page #13

Open
peteryates opened this issue Feb 13, 2022 · 1 comment
Open

Better control of the order of items on the page #13

peteryates opened this issue Feb 13, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@peteryates
Copy link
Member

peteryates commented Feb 13, 2022

Currently the suggested way to build pages is via the wizardry_content helper. This means that if you set your heading above the helper, the <h1> will appear before the error summary.

The two approaches we can use to fix this are:

Make wizardry_content cleverer

Form pages that follow the GOV.UK design system tend to have one or two questions per page. When there's one question, sometimes the <h1> is the input's label or legend. For example, in the checkbox documentation the heading is set like this:

<legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
  <h1 class="govuk-fieldset__heading">
    Which types of waste do you transport?
  </h1>
</legend>

On other pages the heading is set first and the questions follow.

Correctly-positioning the error summary would mean that we need to allow render_form to take care of rendering the heading - it would need to be able to determine whether or not the heading will be rendered as a separate <h1> or if it'll be formed from the first field label or legend.

Allow the content to be rendered bit by bit

Another approach would be to expose some of the functionality that render_form uses and give writers the ability to add the parts of a page individually. Something along the lines of:

<%= wizardry_page(@wizard) do |w| %>
  <%= w.back_button %>
  <%= w.error_summary %>
  <%= tag.h1(@wizard.current_page.title, class: "govuk-heading-l") %>
  <%= w.form %>
<% end %>

This would need to be done on a page-by-page basis when forms have a mix of pages where the heading is set via a label or legend or standalone.

Refs DFE-Digital/find-a-lost-trn/pull/23

@peteryates peteryates added the enhancement New feature or request label Feb 13, 2022
@tvararu
Copy link

tvararu commented Feb 13, 2022

I really like the bit by bit option, as it also allows opting in/out of functionality like the back button. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants