Skip to content

Commit

Permalink
Fix Tabs issue where getting focused while entering the screen
Browse files Browse the repository at this point in the history
  • Loading branch information
gnbm committed Oct 15, 2024
1 parent 8687765 commit 408e205
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
4 changes: 2 additions & 2 deletions src/scripts/OSFramework/OSUI/Helper/Dates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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)));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/OSFramework/OSUI/Helper/Times.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions src/scripts/OSFramework/OSUI/Pattern/Tabs/Tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 408e205

Please sign in to comment.