Skip to content
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

Fix: Open empty action sidebar on back navigation #4154

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

mmioana
Copy link
Contributor

@mmioana mmioana commented Jan 21, 2025

Fix: Open empty action sidebar on back navigation

Description

  • The original issue stated the Redo action opens an empty action sidebar, even though this is no longer reproducible.
Screen.Recording.2025-01-23.at.11.50.20.mov
  • However there was an issue when opening a completed action, followed by the action sidebar back button and then using the browser back button a couple of time that would trigger the empty action sidebar being shown.
Screen.Recording.2025-01-23.at.12.01.24.mov

This was mainly caused by the fact that on back navigation, if the action sidebar was opened, we didn't react to the absence of a txHash and actionType. So my solution involved listening to location key changes (the key should update once the navigation history updates) and if there is no txHash and actionType present, to close the action sidebar.
Additionally, we were mutating the history state needlessly by always performing a navigation without the txHash upon closing the action sidebar, even if there was no txHash set, so I have fixed that.

Important

If you do find a better solution or approach, please do reach out

On this branch

Screen.Recording.2025-01-23.at.13.53.07.mov

Testing

TODO: Let's test the browser back navigation no longer opens an empty action sidebar.

  • Step 1. Go to http://localhost:9091/planex
  • Step 2. Open a completed action. Click on the action sidebar back button
    Screenshot 2025-01-23 at 14 06 48
  • Step 3. Now click a couple of times on the browser back button
  • Step 4. Check the empty action sidebar is not present
  • Step 5. Try redoing an action
  • Step 6. Click again on the browser back button
  • Step 7. Create a new action and complete it (eg. Mint tokens)
  • Step 8. Click again on the browser back button
  • Step 9. Now let's create a new colony by running the create-colony-url script. Complete the colony creation form.
  • Step 10. On the dashboard, go to the Recent Activity table
    Screenshot 2025-01-23 at 14 10 50
  • Step 11. Click on the Create new action button. Check it still opens the empty action sidebar.
  • Step 12. Click on the back navigation. It should redirect to the colony creation form

Please try also whatever other scenario comes to mind.

Diffs

New stuff

  • useLocationKeyChange hook

Changes 🏗

  • Use the actionSidebarInitialValues?.[ACTION_TYPE_FIELD_NAME] in the ColonyLayout
  • Get the current txHash and perform the navigation on action sidebar close only if it exists in ActionSidebarContextProvider

Resolves #3890

@mmioana mmioana self-assigned this Jan 21, 2025
Fix: Open empty action sidebar on back navigation
@mmioana mmioana force-pushed the fix/3890-empty-action-sidebar branch from 2c7b7ff to 4fa9c23 Compare January 23, 2025 12:55
@mmioana mmioana marked this pull request as ready for review January 23, 2025 13:17
@mmioana mmioana requested a review from a team as a code owner January 23, 2025 13:17
Copy link
Contributor

@iamsamgibbs iamsamgibbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, this is working great. I like the solution.

Testing it out, everything works as I assume it would:

Screen.Recording.2025-01-24.at.10.47.36.mov

Testing the colony creation flow:

Screen.Recording.2025-01-24.at.10.48.59.mov

Copy link
Member

@rdig rdig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good here. Nice solution!

Screencast.from.2025-01-24.14-09-02.mp4

I did however find that on the Advance Payments action we don't have a back button. Is that expected, or just an oversight ?

image

Copy link
Contributor

@Nortsova Nortsova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome solution :) I am also faced with random Empty Sidebar sometimes but wasn't able to understand a pattern for it 😄

Thank you ✨ It works great
back-01
back-02
back-03

@@ -62,10 +62,15 @@ const ActionSidebarContextProvider: FC<PropsWithChildren> = ({ children }) => {
const selectedDomain = useGetSelectedDomainFilter();
const selectedDomainNativeId = selectedDomain?.nativeId ?? '';
const navigate = useNavigate();
const [searchParams] = useSearchParams();
const transactionId = searchParams?.get(TX_SEARCH_PARAM);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small comment here: we can rename transactionId to have "param" in its naming for more clarity at 70 line 🙌 But it is not necessary if you don't feel doing it 🫶

Suggested change
const transactionId = searchParams?.get(TX_SEARCH_PARAM);
const transactionIdParam = searchParams?.get(TX_SEARCH_PARAM);

@mmioana mmioana merged commit 8481adf into master Jan 27, 2025
2 checks passed
@mmioana mmioana deleted the fix/3890-empty-action-sidebar branch January 27, 2025 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Actions - QA] Action drawer appears empty when retrying an action
4 participants