Skip to content

Commit 2f79564

Browse files
committed
Fix banner <> redirect race
1 parent 9826ca5 commit 2f79564

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

components/dashboard/src/start/StartWorkspace.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ export interface StartWorkspaceState {
107107
* Set to prevent multiple redirects to the same URL when the User Agent ignores our wish to open links in the same tab (by setting window.location.href).
108108
*/
109109
redirected?: boolean;
110+
/**
111+
* Determines whether `redirected` has been `true` for long enough to display our "new tab" info banner without racing with same-tab redirection in regular setups
112+
*/
113+
showRedirectMessage?: boolean;
110114
}
111115

112116
// TODO: use Function Components
@@ -474,6 +478,9 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
474478
}
475479

476480
this.setState({ redirected: true });
481+
setTimeout(() => {
482+
this.setState({ showRedirectMessage: true });
483+
}, 2000);
477484
}
478485

479486
private openDesktopLink(link: string) {
@@ -767,7 +774,7 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
767774
workspaceId={this.props.workspaceId}
768775
>
769776
{statusMessage}
770-
{this.state.redirected && (
777+
{this.state.showRedirectMessage && (
771778
<>
772779
<Alert type="info" className="mt-4 w-112">
773780
We redirected you to your workspace, but your browser probably opened it in another tab.

0 commit comments

Comments
 (0)