Fix incorrect redirect after deleting an item from details page#8159
Fix incorrect redirect after deleting an item from details page#8159robert-md-or wants to merge 6 commits into
Conversation
reecertc
left a comment
There was a problem hiding this comment.
appRouter.back() works when the item was opened from a library, but the previous page is not always a safe place to return to. The details page might have been opened from a bookmark, or the previous page might be an item that was also deleted.
Could we keep the existing parent/home navigation as a fallback when there is no safe page to return to? This would fix the redirect without leaving the user on a deleted item page.
|
Updated the fix to include a fallback navigation as suggested. Now uses appRouter.back() when history is available, falls back to parent item navigation, and goes home as last resort. |
reecertc
left a comment
There was a problem hiding this comment.
One more issue: canGoBack() uses window.history.length, but opening the context menu and confirmation increases that value even after they close. This means a directly opened details page can still take the back branch instead of the new fallback, leaving the router stuck.
You can keep the fallback and just update canGoBack()
-return window.history.length > 1;
+return (window.history.state?.idx ?? 0) > 0;Should be good to go after this 👍🏻
|
Updated canGoBack() to use window.history.state?.idx instead of window.history.length as suggested. Thanks for the catch! |
|



Changes
When deleting an item from the details page, use appRouter.back() to return to the previous page instead of navigating to the parent item, which was generating a legacy URL.
Issues
Fixes #8106
Code assistance
Used Claude AI for codebase navigation. Fix and testing are my own.
Before:

After:
