From 5c192a5b00abf05d80f36d1fad8b67a79a36e43c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Staffan=20Edstr=C3=B6m?= Date: Thu, 23 Feb 2023 14:28:28 +0000 Subject: [PATCH] fix: scroll error into view with nested key names (#904) * fix: scroll error into view with nested key names --- addon/components/validated-button.js | 2 +- addon/components/validated-form.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addon/components/validated-button.js b/addon/components/validated-button.js index 1b5c543e..84f4451d 100644 --- a/addon/components/validated-button.js +++ b/addon/components/validated-button.js @@ -43,7 +43,7 @@ export default class ValidatedButtonComponent extends Component { if (macroCondition(getOwnConfig().scrollErrorIntoView)) { if (model.errors[0]?.key) { document - .querySelector(`[name=${model.errors[0].key}]`) + .querySelector(`[name=${model.errors[0].key.replaceAll(".", "\\.")}]`) ?.scrollIntoView({ behavior: "smooth" }); } } diff --git a/addon/components/validated-form.js b/addon/components/validated-form.js index 1248d379..081390fa 100644 --- a/addon/components/validated-form.js +++ b/addon/components/validated-form.js @@ -48,7 +48,9 @@ export default class ValidatedFormComponent extends Component { if (macroCondition(getOwnConfig().scrollErrorIntoView)) { if (model.errors[0]?.key) { document - .querySelector(`[name=${model.errors[0].key}]`) + .querySelector( + `[name=${model.errors[0].key.replaceAll(".", "\\.")}]` + ) ?.scrollIntoView({ behavior: "smooth" }); } }