Fix empty screen flash before nav on clicking project in top bar #2156
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed some janky behavior on nav when I click the project in the top bar.
2024-04-16-project-click-bug.mp4
This was due to that link going to
/projects/my-proj
, which is not actually a real page in its own right: it does a client-side redirect to/project/my-proj/instances
. In general our approach in cases like this (a parent route with a default child that we always redirect to) is to link directly to the default child.But I noticed is that path builder is not set up to encourage the right choice.
pb.project()
went to/projects/my-proj
because it is used in the construction of many other paths, even though we don't actually ever want to link there. So what I did here is pull out aprojectBase
helper function that is used as the base for other routes, and changedpb.project()
to go straight to/projects/my-proj/instances
. This fixes the flash on the link in the top bar.The other thing I did that's sort of subtle is that I changed some calls to
pb.instances()
topb.project()
even though they return the same route. I wanted to go according to the semantics of the call site instead of what we know the resulting path to be. For example, if the user creates a project, we want to land on the project detail. That previously went topb.instances()
because that is the correct path to land on. But what we want to land on in that case is not necessarily project instances, it's whatever the project detail path happens to be, which in this case is project instances, but it may not be in the future.