Skip to content

Commit

Permalink
Merge pull request #999 from OutSystems/ROU-11287
Browse files Browse the repository at this point in the history
ROU-11287: [OSUI] - Defect with Skip to Content link
  • Loading branch information
JoaoFerreira-FrontEnd authored Oct 18, 2024
2 parents 572f143 + 3a72361 commit 13d3585
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/scripts/OutSystems/OSUI/Utils/Accessibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => {
Expand All @@ -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();
}
Expand Down

0 comments on commit 13d3585

Please sign in to comment.