diff --git a/app/controllers/submit_form_controller.rb b/app/controllers/submit_form_controller.rb index 2588c711c..d5fa25fec 100644 --- a/app/controllers/submit_form_controller.rb +++ b/app/controllers/submit_form_controller.rb @@ -39,6 +39,10 @@ def show # Fetch prefill values if available @prefill_values = fetch_prefill_values_if_available + # When the URL contains expand=true, keep the form panel expanded on desktop + # instead of auto-minimizing when the current field is signature/initials/file/image. + @expand = params[:expand] == 'true' + @attachments_index = build_attachments_index(submission) return unless @form_configs[:prefill_signature] diff --git a/app/views/submit_form/show.html.erb b/app/views/submit_form/show.html.erb index 946b9e6a0..f5aa4ed4d 100644 --- a/app/views/submit_form/show.html.erb +++ b/app/views/submit_form/show.html.erb @@ -68,7 +68,7 @@
- <%= render 'submit_form/submission_form', attachments_index: @attachments_index, submitter: @submitter, signature_attachment: @signature_attachment, configs: @form_configs, dry_run: local_assigns[:dry_run], expand: local_assigns[:expand], scroll_padding: local_assigns.fetch(:scroll_padding, '-110px'), schema:, values: values %> + <%= render 'submit_form/submission_form', attachments_index: @attachments_index, submitter: @submitter, signature_attachment: @signature_attachment, configs: @form_configs, dry_run: local_assigns[:dry_run], expand: @expand || local_assigns[:expand], scroll_padding: local_assigns.fetch(:scroll_padding, '-110px'), schema:, values: values %>
diff --git a/spec/system/signing_form_spec.rb b/spec/system/signing_form_spec.rb index 3c86f7a3d..705a75dfb 100644 --- a/spec/system/signing_form_spec.rb +++ b/spec/system/signing_form_spec.rb @@ -342,6 +342,33 @@ end end + context 'when the signature step is opened with expand=true' do + let(:template) { create(:template, account:, author:, only_field_types: %w[signature]) } + let(:submission) { create(:submission, template:) } + let(:submitter) do + create(:submitter, submission:, uuid: template.submitters.first['uuid'], account:) + end + + it 'keeps the form panel expanded without needing to click Sign Now' do + visit submit_form_path(slug: submitter.slug, expand: 'true') + + # The expand (Sign Now) button is absent because the panel is already open + expect(page).not_to have_selector('#expand_form_button') + expect(page).to have_selector('#form_container') + + # The signature canvas is directly accessible + draw_canvas + click_button 'Sign and Complete' + + expect(page).to have_content('Document has been signed!') + + submitter.reload + + expect(submitter.completed_at).to be_present + expect(field_value(submitter, 'Signature')).to be_present + end + end + context 'when the multiple choice step' do let(:template) { create(:template, account:, author:, only_field_types: %w[multiple]) } let(:submission) { create(:submission, template:) }