-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix: Issue #9225 Solved #10028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Fix: Issue #9225 Solved #10028
Conversation
|
Could you please update the PR description to clearly reflect the actual purpose of the changes?
I’m not against adding a return/back button — it can be useful — but please note that browser history may be empty. In such cases the button must redirect to the appropriate main page depending on the resource type (tasks → tasks list, projects → projects list, etc.). Also, please add a changelog entry describing the feature. |
Refactor not found components to use a common handleReturn function for navigation.
Remove console log for history length in TaskNotFoundComponent.
Added a new 'Return to Previous Page' button with smart fallback navigation.
Updated link for 'Return to Previous Page' button feature.
|
Hey @klakhov Sorry for the inconvience of the PR description. In short I tried to solve the problem of Issue: #9225 . Also Thanks for picking out the edge case of browser history being empty, that case has now been handled, too. I basically used useHistory to navigate if incase user goes like tasks/2?page=2 -> tasks/3232(which may not exist) to return him/her again to tasks/2?page=2. If he directly goes to tasks/3232 if it doesn't exist the button will redirect it to /tasks/ |
| <a id='changelog-2.50.0'></a> | ||
| ## \[2.50.0\] - 2025-11-26 | ||
|
|
||
| ### Added | ||
|
|
||
| - "Return to Previous Page" button on Task, Project, Job, and Cloud Storage Not Found pages | ||
| with smart fallback navigation: navigates back in history if available, otherwise redirects | ||
| to the appropriate resource list page | ||
| (<https://github.com/cvat-ai/cvat/pull/10028>) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to use text:
### Added
- "Return to Previous Page" button on Task, Project, Job, and Cloud Storage Not Found pages
Also, do not modify this file directly. Our project uses scriv to handle changelogs to avoid merge conflicts.
To use it use the command from the note of CHANGELOG.md below:
Developers: this project uses scriv (<https://scriv.readthedocs.io/en/stable/index.html>)
to maintain the changelog. To add an entry, create a fragment:
$ scriv create --edit
Fragments will be merged into this file whenever a release is made.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted, thanks
| const handleReturn = () => { | ||
| if (history.length > 2) { | ||
| history.goBack(); | ||
| } else { | ||
| history.push('/jobs'); | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code of this function is duplicated, need to extract and re-use the logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, why do we use >2? Shouldnt it be '>1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup i have extracted and reused the logic now
I used the '>1' in the code first-hand but then I came across the unusual behaviour of browser history, that they count homepage in history so if user navigates to http://127.0.0.1:3000/tasks/1365 which does not exist directly from the homepage and if the condition is '>1' rather than '>2', it will redirect the user to homepage of browser after clicking the button that I have added rather than taking him to http://127.0.0.1:3000/tasks. So to counter it, I used '>2' which solves this edge case
Updated the link for the 'Return to Previous Page' button in the changelog.
|



Problem:
When users navigate to non-existent resources (invalid task ID, project ID, job ID, or cloud storage ID), they see a Not Found error page but have no easy way to navigate back. They must either:
Solution:
This PR adds a "Return to Previous Page" button to Not Found pages with smart fallback logic:
history.goBack()(preserves query parameters and navigation context)/tasks/projects/jobs/cloudstoragesChanges implemented:
TaskNotFoundComponent,ProjectNotFoundComponent, andCloudStorageNotFoundComponentResult.extraprop (centered by Ant Design)useHistory()hook with smart fallback:File affected:
cvat-ui/src/components/common/not-found.tsxHow has this been tested?
Manual verification steps performed locally:
cd cvat-ui yarn install yarn startTested navigation scenarios for each Not Found page:
Scenario A: Browser history exists (normal navigation)
/tasks)/tasks/99999)/taskspreserving any query parametersScenario B: Direct URL access (no browser history)
http://localhost:3000/tasks/99999)/tasks(appropriate fallback)Tested for all Not Found pages:
/tasks/invalid-id→ fallback to/tasks/projects/invalid-id→ fallback to/projects/jobs/invalid-id→ fallback to/jobs/cloudstorages/invalid-id→ fallback to/cloudstoragesConfirmed:
history.goBack()Verified TypeScript and lint checks in UI folder:
cd cvat-ui yarn run type-check yarn run lintNote: All checks passed locally for this change.
Checklist
developbranchChangelog
Added: