Skip to content

Commit

Permalink
change fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tongsonbarbs committed Sep 26, 2024
1 parent 057905c commit a75dbd3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/devextreme/js/ui/shared/accessibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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]');
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a75dbd3

Please sign in to comment.