From 3a72361b0c5c13c75cd06161b93e5a563d69c982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira?= Date: Fri, 18 Oct 2024 11:53:12 +0100 Subject: [PATCH] - remove tabIndex on a target blur listener; - add blur function to remove tabindex and listener; --- src/scripts/OutSystems/OSUI/Utils/Accessibility.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/scripts/OutSystems/OSUI/Utils/Accessibility.ts b/src/scripts/OutSystems/OSUI/Utils/Accessibility.ts index 65fcf95219..c903b83066 100644 --- a/src/scripts/OutSystems/OSUI/Utils/Accessibility.ts +++ b/src/scripts/OutSystems/OSUI/Utils/Accessibility.ts @@ -99,6 +99,18 @@ namespace OutSystems.OSUI.Utils.Accessibility { * @param targetId */ export function SkipToContent(targetId: string): string { + // Method to remove tabindex from skipToContent at onBlur + function _skipToContentOnBlur(e: FocusEvent): void { + OSFramework.OSUI.Helper.AsyncInvocation(() => { + const target = e.target as HTMLElement; + + if (target) { + OSFramework.OSUI.Helper.Dom.Attribute.Remove(target, 'tabindex'); + target.removeEventListener(OSFramework.OSUI.GlobalEnum.HTMLEvent.Blur, _skipToContentOnBlur); + } + }); + } + const result = OutSystems.OSUI.Utils.CreateApiResponse({ errorCode: ErrorCodes.Utilities.FailSkipToContent, callback: () => { @@ -110,7 +122,7 @@ namespace OutSystems.OSUI.Utils.Accessibility { if (isFocusable === undefined) { OSFramework.OSUI.Helper.Dom.Attribute.Set(target, 'tabindex', '0'); target.focus(); - OSFramework.OSUI.Helper.Dom.Attribute.Remove(target, 'tabindex'); + target.addEventListener(OSFramework.OSUI.GlobalEnum.HTMLEvent.Blur, _skipToContentOnBlur); } else { target.focus(); }