Skip to content

Commit

Permalink
Fix back link in notes page
Browse files Browse the repository at this point in the history
This updates the notes page to use the history stack, this fixes an
unusual flow where the back link would end up in a loop.
  • Loading branch information
thomasleese committed Feb 21, 2024
1 parent 423c109 commit 4fba133
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/controllers/assessor_interface/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def create
)

if @form.save
redirect_to params[:next].presence ||
redirect_to history_stack.pop_back ||
[:assessor_interface, application_form]
else
render :new, status: :unprocessable_entity
Expand Down
4 changes: 1 addition & 3 deletions app/views/assessor_interface/notes/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<% content_for :page_title, title_with_error_prefix("Add a note", error: @form.errors.any?) %>
<% content_for :back_link_url, params[:next].presence || assessor_interface_application_form_path(@application_form) %>
<% content_for :back_link_url, back_history_path(default: assessor_interface_application_form_path(@application_form)) %>

<%= form_with model: @form, url: [:assessor_interface, @application_form, :notes] do |f| %>
<%= hidden_field_tag :next, params[:next] %>

<%= f.govuk_error_summary %>

<%= f.govuk_text_area :text, label: { tag: "h1", size: "l" }, rows: 5 %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_assessor_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<h1 class="govuk-heading-xl"><%= title %></h1>

<%= govuk_button_link_to "Add&nbsp;note".html_safe,
new_assessor_interface_application_form_note_path(application_form, next: request.path),
[:new, :assessor_interface, @application_form, :note],
secondary: true %>
</div>

0 comments on commit 4fba133

Please sign in to comment.