From 408e20502d0c64b72a6c04cdaca6954e613a9efb Mon Sep 17 00:00:00 2001 From: gnbm Date: Tue, 15 Oct 2024 22:37:12 +0100 Subject: [PATCH] Fix Tabs issue where getting focused while entering the screen --- package.json | 2 +- src/scripts/OSFramework/OSUI/Helper/Dates.ts | 4 ++-- src/scripts/OSFramework/OSUI/Helper/Times.ts | 2 +- src/scripts/OSFramework/OSUI/Pattern/Tabs/Tabs.ts | 6 ++++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 7825487401..e84f66fdf7 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,6 @@ "typedoc-plugin-merge-modules": "^4.0.1", "typedoc-umlclass": "^0.7.0", "typescript": "^4.5.0", - "virtual-select-plugin": "^1.0.45" + "virtual-select-plugin": "^1.0.46" } } \ No newline at end of file diff --git a/src/scripts/OSFramework/OSUI/Helper/Dates.ts b/src/scripts/OSFramework/OSUI/Helper/Dates.ts index 56d6997f4c..1859862d7d 100644 --- a/src/scripts/OSFramework/OSUI/Helper/Dates.ts +++ b/src/scripts/OSFramework/OSUI/Helper/Dates.ts @@ -52,7 +52,7 @@ namespace OSFramework.OSUI.Helper { // Check if the given date is not a date object and if it's a valid date if (typeof date === 'string') { // Check if string could be parsed into a date - If it has an expected dateformat - if (isNaN(Date.parse(date))) { + if (Number.isNaN(Date.parse(date))) { throw new Error(`The given date '${date}' it's not a valid date.`); } _date = new Date(Date.parse(date)); @@ -80,7 +80,7 @@ namespace OSFramework.OSUI.Helper { * @memberof Dates */ public static IsValid(date: string): boolean { - return !isNaN(Number(this.NormalizeDate(date))); + return !Number.isNaN(Number(this.NormalizeDate(date))); } /** diff --git a/src/scripts/OSFramework/OSUI/Helper/Times.ts b/src/scripts/OSFramework/OSUI/Helper/Times.ts index 9b8010c474..db3d403cb4 100644 --- a/src/scripts/OSFramework/OSUI/Helper/Times.ts +++ b/src/scripts/OSFramework/OSUI/Helper/Times.ts @@ -28,7 +28,7 @@ namespace OSFramework.OSUI.Helper { * @memberof OSFramework.Helper.Times */ public static IsNull(time: string): boolean { - if (isNaN(Date.parse(time))) { + if (Number.isNaN(Date.parse(time))) { // Check if the given time is not a time object and if it's a valid time if (typeof time === Constants.JavaScriptTypes.String) { const isValid = /^([0-1]?[0-9]|2[0-4]):([0-5][0-9])(:[0-5][0-9])?$/.test(time); diff --git a/src/scripts/OSFramework/OSUI/Pattern/Tabs/Tabs.ts b/src/scripts/OSFramework/OSUI/Pattern/Tabs/Tabs.ts index bfd102888e..ce152d30a3 100644 --- a/src/scripts/OSFramework/OSUI/Pattern/Tabs/Tabs.ts +++ b/src/scripts/OSFramework/OSUI/Pattern/Tabs/Tabs.ts @@ -185,7 +185,9 @@ namespace OSFramework.OSUI.Patterns.Tabs { this._activeTabContentElement = newContentItem; } - if (this._hasDragGestures) { + // Set focus on the new active header element when running on a device with drag gestures + // and the tabs are built to make sure if only runs after the tabs are built + if (this._hasDragGestures && this.isBuilt) { this._activeTabHeaderElement.setFocus(); } @@ -397,7 +399,7 @@ namespace OSFramework.OSUI.Patterns.Tabs { // If at this moment the active item has no size (NaN), set an observer to run this method when its size is changed // This happens, as an example, when there're tabs inside tabs, and inner one has no size when it's built, due to being on a non-active tab - if (isNaN(_finalSize) || _finalSize === 0) { + if (Number.isNaN(_finalSize) || _finalSize === 0) { const resizeObserver = new ResizeObserver((entries) => { for (const entry of entries) { if (entry.contentBoxSize) {