fixed reg trunk validation cannot move tab and focus to missing fields

This commit is contained in:
Hoan HL
2025-10-27 09:27:58 +07:00
parent eff96bd32c
commit a0dc97487b
@@ -921,6 +921,17 @@ export const CarrierForm = ({
if (activeTab !== targetTab) {
e.preventDefault(); // Stop the "not focusable" error
setActiveTab(targetTab);
setTimeout(() => {
const field =
document.getElementById(fieldName) ||
document.querySelector(`[name="${fieldName}"]`);
if (field && field instanceof HTMLInputElement) {
field.focus();
field.scrollIntoView({ behavior: "smooth", block: "center" });
field.reportValidity();
}
}, 100);
}
};