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

Add automatic scrolling of wizard steps #14826

Open
wants to merge 4 commits into
base: 3.x
Choose a base branch
from
Open
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
15 changes: 9 additions & 6 deletions packages/forms/resources/views/components/wizard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
this.step = this.getSteps()[nextStepIndex]

this.autofocusFields()
this.scrollToTop()
this.scroll()
},

previousStep: function () {
Expand All @@ -34,13 +34,15 @@
this.step = this.getSteps()[previousStepIndex]

this.autofocusFields()
this.scrollToTop()
this.scroll()
},

scrollToTop: function () {
this.$nextTick(() =>
this.$root.scrollIntoView({ behavior: 'smooth', block: 'start' }),
)
scroll: function () {
this.$nextTick(() => {
this.$refs.header.children[
this.getStepIndex(this.step)
].scrollIntoView({ behavior: 'smooth', block: 'start' })
})
},

autofocusFields: function () {
Expand Down Expand Up @@ -135,6 +137,7 @@
'border-b border-gray-200 dark:border-white/10' => $isContained,
'rounded-xl bg-white shadow-sm ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10' => ! $isContained,
])
x-ref="header"
>
@foreach ($getChildComponentContainer()->getComponents() as $step)
<li
Expand Down
Loading