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: user hub placement #2637

Merged
merged 1 commit into from
Jul 12, 2024
Merged

fix: user hub placement #2637

merged 1 commit into from
Jul 12, 2024

Conversation

joanna-pagepro
Copy link
Contributor

Description

Fix for transaction pending button overlapping issue

Testing

  • Step 1. Create an action, so that the side panel is open.
  • Step 2. Click on the UserHub.
  • Step 3. Click on the Activate button.
  • Step 4. Activate some tokens.
  • Step 5. Check if the transaction pending button is still overlapping.

Diffs

New stuff

Changes 🏗

  • blur-related styles are now added to elements with modal-blur or modal-blur-navigation classes
  • there's no duplication of the user navigation component on the desktop view - the same component is shown when a modal is open and closed
  • The user navigation component is moved to the top when the shouldShowHeader prop is passed to the Modal component

Deletions ⚰️

TODO

  • Add TODOs

Resolves #2456

@joanna-pagepro joanna-pagepro self-assigned this Jul 2, 2024
@joanna-pagepro joanna-pagepro requested review from a team as code owners July 2, 2024 10:54
@joanna-pagepro joanna-pagepro force-pushed the fix/15935062-pending-pill branch from 3968f9e to c2d36dc Compare July 2, 2024 10:55
Copy link

@melyndav melyndav left a comment

Choose a reason for hiding this comment

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

Hey @joanna-pagepro 🦖

When I attempt to test this, the userhub closes the side panel and then automatically closes straight after as shown in the recording below:

Export-1720010849272

@mmioana mmioana self-requested a review July 11, 2024 07:57
@joanna-pagepro joanna-pagepro force-pushed the fix/15935062-pending-pill branch from c2d36dc to de27a70 Compare July 11, 2024 08:14
@joanna-pagepro
Copy link
Contributor Author

@melyndav please review it again

@joanna-pagepro joanna-pagepro requested a review from melyndav July 11, 2024 08:14
melyndav
melyndav previously approved these changes Jul 11, 2024
Copy link

@melyndav melyndav left a comment

Choose a reason for hiding this comment

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

Thanks for that fix @joanna-pagepro, I've been able to test it and everything is looking resolved now. nice work! 👍

Export-1720688781133

Copy link
Contributor

@mmioana mmioana left a comment

Choose a reason for hiding this comment

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

Cool work @joanna-pagepro
I didn't manage to reproduce the issue anymore 👍 however I left some code refactoring comments

@@ -51,7 +53,12 @@ const ActionSidebarContextProvider: FC<PropsWithChildren> = ({ children }) => {

actionSidebarUseRegisterOnBeforeCloseCallback((element) => {
const isClickedInside = isElementInsideModalOrPortal(element);
if (!isClickedInside) {
const navigationWrapper = document.querySelector('.modal-blur-navigation');
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please refactor document.querySelector in a utils function?

const getElementWithSelector = (selector) => document.querySelector(selector);

and use it here const navigationWrapper = getElementWithSelector('.modal-blur-navigation')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is the advantage of doing so?

Copy link
Contributor

Choose a reason for hiding this comment

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

The advantage would be to abstract the way elements are selected.
In case additional logic will be needed in the future, eg. log an error if the element is not found for a specific selector, only the utility function will need to be updated.

Comment on lines 31 to 44

useEffect(() => {
if (
isOpen &&
shouldShowHeader &&
!document.body.classList.contains('show-header-in-modal')
) {
document.body.classList.add('show-header-in-modal');
}

return () => {
document.body.classList.remove('show-header-in-modal');
};
}, [isOpen, shouldShowHeader]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we extract this in a hook?

const useAddClassToElement = ({ shouldAddClass, element, className }) => {

 useEffect(() => {
    if (
      shouldAddClass &&
      !element.classList.contains(className)
    ) {
      element.classList.add(className);
    }

    return () => {
      element.classList.remove(className);
    };
  }, [shouldAddClass, element, className]);

}

And use it here as

useAddClassToElement({ 
  shouldAddClass: isOpen && shouldShowHeader,
  className: 'show-header-in-modal',
  element: document.body
})


if (
!isClickedInside ||
(navigationWrapper && navigationWrapper.contains(element) && !isTablet)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please refactor this part navigationWrapper && navigationWrapper.contains(element) into an utils function?

const isChildOf = (parent, child) => parent && parent.contains(child);

and use it here (isChildOf(navigationWrapper, element) && !isTablet)

className={clsx(
'modal-blur-navigation [.show-header-in-modal_&]:z-[1001]',
{
'relative z-[11]': !isTablet,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is anything stopping us from using z-20?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just think that 11 is enough here. I haven't tested it with 20

Copy link
Contributor

Choose a reason for hiding this comment

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

Just dropping a note to say it is preferred to use the z-index values in tailwind.config.js rather than arbitrary values.

Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, we could add these values (11 and 1001) in tailwind.config.js if the already defined values are not usable in this scenario

@joanna-pagepro
Copy link
Contributor Author

@mmioana can you check the changes and my answers?

Copy link
Contributor

@mmioana mmioana left a comment

Choose a reason for hiding this comment

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

Thank you @joanna-pagepro for your prompt changes! 💮
Could please tackle also the other two comments?

@joanna-pagepro joanna-pagepro force-pushed the fix/15935062-pending-pill branch from e397138 to 85cf431 Compare July 12, 2024 07:21
@joanna-pagepro
Copy link
Contributor Author

@mmioana done

Copy link
Contributor

@mmioana mmioana left a comment

Choose a reason for hiding this comment

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

Thank you @joanna-pagepro for your work! 🚀 💟

Copy link

@melyndav melyndav left a comment

Choose a reason for hiding this comment

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

Re-approving this one @joanna-pagepro! Thanks again for your work. 🤩

@joanna-pagepro joanna-pagepro merged commit f7fc9bf into master Jul 12, 2024
4 of 6 checks passed
@joanna-pagepro joanna-pagepro deleted the fix/15935062-pending-pill branch July 12, 2024 12:30
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.

Fix issue with overlapping transaction pending pill
4 participants