Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Canvas
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sc07
Canvas
Commits
0cf27d80
Commit
0cf27d80
authored
9 months ago
by
Grant
Browse files
Options
Downloads
Patches
Plain Diff
fix initial client load position (fixes
#36
)
parent
6308992e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/client/src/contexts/TemplateContext.tsx
+17
-1
17 additions, 1 deletion
packages/client/src/contexts/TemplateContext.tsx
packages/client/src/lib/router.ts
+1
-1
1 addition, 1 deletion
packages/client/src/lib/router.ts
with
18 additions
and
2 deletions
packages/client/src/contexts/TemplateContext.tsx
+
17
−
1
View file @
0cf27d80
...
...
@@ -3,6 +3,7 @@ import {
createContext
,
useContext
,
useEffect
,
useRef
,
useState
,
}
from
"
react
"
;
import
{
IRouterData
,
Router
}
from
"
../lib/router
"
;
...
...
@@ -52,7 +53,11 @@ export const TemplateContext = ({ children }: PropsWithChildren) => {
const
[
y
,
setY
]
=
useState
(
routerData
.
template
?.
y
||
0
);
const
[
opacity
,
setOpacity
]
=
useState
(
100
);
const
initAt
=
useRef
<
number
>
();
useEffect
(()
=>
{
initAt
.
current
=
Date
.
now
();
const
handleNavigate
=
(
data
:
IRouterData
)
=>
{
if
(
data
.
template
)
{
setEnable
(
true
);
...
...
@@ -74,7 +79,18 @@ export const TemplateContext = ({ children }: PropsWithChildren) => {
useEffect
(()
=>
{
Router
.
setTemplate
({
enabled
:
enable
,
width
,
x
,
y
,
url
});
Router
.
queueUpdate
();
if
(
!
initAt
.
current
)
{
console
.
debug
(
"
TemplateContext updating router but no initAt
"
);
}
else
if
(
Date
.
now
()
-
initAt
.
current
<
2
*
1000
)
{
console
.
debug
(
"
TemplateContext updating router too soon after init
"
,
Date
.
now
()
-
initAt
.
current
);
}
if
(
initAt
.
current
&&
Date
.
now
()
-
initAt
.
current
>
2
*
1000
)
Router
.
queueUpdate
();
},
[
enable
,
width
,
x
,
y
,
url
]);
return
(
...
...
This diff is collapsed.
Click to expand it.
packages/client/src/lib/router.ts
+
1
−
1
View file @
0cf27d80
...
...
@@ -70,7 +70,7 @@ class _Router extends EventEmitter<RouterEvents> {
const
url
=
this
.
getURL
();
if
(
!
url
)
return
;
console
.
log
(
"
[Router] Updating URL
"
);
console
.
log
(
"
[Router] Updating URL
"
,
url
);
window
.
history
.
replaceState
({},
""
,
url
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment