some fix
This commit is contained in:
1 parent
6b841dc5fa
commit
0ed677e5fc
10 files changed
+282
-16
No files matched your search
@@ -18,6 +18,22 @@
|
||||
|
||||
const toPersianDigits = value => String(value).replace(/\d/g, digit => '۰۱۲۳۴۵۶۷۸۹'[digit]);
|
||||
|
||||
function focusWizardCard({ respectExistingFocus = false } = {}) {
|
||||
requestAnimationFrame(() => {
|
||||
if (
|
||||
respectExistingFocus
|
||||
&& document.activeElement !== document.body
|
||||
&& document.activeElement !== document.documentElement
|
||||
) return;
|
||||
form.focus({ preventScroll: true });
|
||||
form.scrollIntoView({
|
||||
behavior: window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth',
|
||||
block: 'start',
|
||||
inline: 'nearest',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function updateProgress(number) {
|
||||
progress.forEach(item => {
|
||||
const itemNumber = Number(item.dataset.wizardProgressItem);
|
||||
@@ -35,7 +51,7 @@
|
||||
step.classList.toggle('is-active', active);
|
||||
});
|
||||
updateProgress(number);
|
||||
if (scroll) window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
if (scroll) focusWizardCard();
|
||||
}
|
||||
|
||||
function clearValidation(number) {
|
||||
@@ -349,19 +365,6 @@
|
||||
setupVoiceRecorder(voiceRoot);
|
||||
form.dataset.wizardEnhanced = '';
|
||||
|
||||
function focusWizardCard() {
|
||||
requestAnimationFrame(() => {
|
||||
// Do not steal focus if the visitor has already started interacting.
|
||||
if (document.activeElement !== document.body && document.activeElement !== document.documentElement) return;
|
||||
form.focus({ preventScroll: true });
|
||||
form.scrollIntoView({
|
||||
behavior: window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth',
|
||||
block: 'start',
|
||||
inline: 'nearest',
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const serverErrorStep = steps.find(step => step.querySelector('.errorlist'));
|
||||
const initialStep = serverErrorStep ? Number(serverErrorStep.dataset.wizardStep) : 1;
|
||||
showStep(initialStep, { scroll: false });
|
||||
@@ -372,5 +375,5 @@
|
||||
.filter(Boolean);
|
||||
const number = Number(serverErrorStep.dataset.wizardStep);
|
||||
requestAnimationFrame(() => showValidation(number, { message: messages.join(' '), fields }));
|
||||
} else focusWizardCard();
|
||||
} else focusWizardCard({ respectExistingFocus: true });
|
||||
})();
|
||||
Reference in new issue
Block a user