Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ export default class CustomWizardComposerEditor extends ComposerEditor {
@bind
setupEditor(textManipulation) {
textManipulation.placeholder.composer = this.composer;

// Core focuses the editor on setup, which would scroll the page past the
// step's title and description.
const textarea = textManipulation.textarea;
if (textarea) {
const focus = textarea.focus.bind(textarea);
textarea.focus = (options) => focus({ ...options, preventScroll: true });
}

super.setupEditor(textManipulation);
}

Expand Down
2 changes: 1 addition & 1 deletion plugin.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
# name: discourse-custom-wizard
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
# version: 2.18.6
# version: 2.18.7
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Marcos Gutierrez
# url: https://github.com/paviliondev/discourse-custom-wizard
# contact_emails: development@pavilion.tech
Expand Down
40 changes: 40 additions & 0 deletions spec/system/wizard_step_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# frozen_string_literal: true

describe "Wizard steps" do
fab!(:user)

let(:tall_description) { (1..40).map { |i| "Paragraph #{i}" }.join("\n\n") }

before do
enable_subscription("standard")
CustomWizard::Template.save(
{
id: "tall_wizard",
name: "Tall wizard",
steps: [
{
id: "step_1",
raw_description: tall_description,
fields: [{ id: "step_1_field_1", type: "text", label: "First" }],
},
{
id: "step_2",
raw_description: tall_description,
fields: [{ id: "step_2_field_1", type: "composer", label: "Second" }],
},
],
}.as_json,
skip_jobs: true,
)
sign_in(user)
end

it "shows the next step from the top when its composer is focused" do
visit("/w/tall-wizard")
page.execute_script("window.scrollTo(0, document.body.scrollHeight)")
find(".wizard-btn.next").click

expect(page).to have_css(".wizard-step.step_2 .d-editor-input:focus")
expect(page.evaluate_script("window.scrollY")).to eq(0)
end
end
Loading