From a75dbd3a8458d020674612a8812e40d5f7826bc1 Mon Sep 17 00:00:00 2001 From: tongsonbarbs Date: Thu, 26 Sep 2024 17:18:03 +0800 Subject: [PATCH] change fix --- packages/devextreme/js/ui/shared/accessibility.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/devextreme/js/ui/shared/accessibility.js b/packages/devextreme/js/ui/shared/accessibility.js index e1f83cd5b32..75e1a9764c0 100644 --- a/packages/devextreme/js/ui/shared/accessibility.js +++ b/packages/devextreme/js/ui/shared/accessibility.js @@ -57,7 +57,7 @@ function processKeyDown(viewName, instance, event, action, $mainElement, execute export function saveFocusedElementInfo(target, instance) { const $target = $(target); - const ariaLabel = $target.attr('aria-label')?.replace(/"/g, '\\"'); + const ariaLabel = $target.attr('aria-label'); const $activeElements = getActiveAccessibleElements(ariaLabel, instance.element()); const targetIndex = $activeElements.index($target); @@ -71,7 +71,8 @@ function getActiveAccessibleElements(ariaLabel, viewElement) { let $activeElements; if(ariaLabel) { - $activeElements = $viewElement.find(`[aria-label="${ariaLabel}"][tabindex]`); + const escapedAriaLabel = ariaLabel?.replace(/"/g, '\\"'); + $activeElements = $viewElement.find(`[aria-label="${escapedAriaLabel}"][tabindex]`); } else { $activeElements = $viewElement.find('[tabindex]'); } @@ -158,7 +159,8 @@ export function restoreFocus(instance) { if(!instance.option('useLegacyKeyboardNavigation') && focusedElementInfo) { const viewInstance = focusedElementInfo.viewInstance; if(viewInstance) { - const $activeElements = getActiveAccessibleElements(focusedElementInfo.ariaLabel, viewInstance.element()); + const escapedAriaLabel = focusedElementInfo.ariaLabel?.replace(/"/g, '\\"'); + const $activeElements = getActiveAccessibleElements(escapedAriaLabel, viewInstance.element()); const $targetElement = $activeElements.eq(focusedElementInfo.index); focusedElementInfo = null;