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

feat: add option to persist modal across navigation changes #2545

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jake-bassett
Copy link
Contributor

Description

Please include a summary of the change, motivation and context.

Testing

Please describe the tests that you ran to verify your changes. Please summarize what did you test and what needs to be tested e.g. deployed and tested helm chart locally.

Checklist:

  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

Documentation

Make sure that you have documented corresponding changes in this repository or hypertrace docs repo if required.

@jake-bassett jake-bassett requested a review from a team as a code owner November 28, 2023 01:09
Copy link

Test Results

       4 files     316 suites   31m 54s ⏱️
1 135 tests 1 135 ✔️ 0 💤 0
1 145 runs  1 145 ✔️ 0 💤 0

Results for commit 0547756.

Copy link

codecov bot commented Nov 28, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2a0fe4e) 82.99% compared to head (0547756) 82.99%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2545   +/-   ##
=======================================
  Coverage   82.99%   82.99%           
=======================================
  Files         925      925           
  Lines       20628    20629    +1     
  Branches     3253     3254    +1     
=======================================
+ Hits        17120    17121    +1     
  Misses       3388     3388           
  Partials      120      120           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -9,6 +9,7 @@ export interface ModalConfig<TData = unknown> {
title?: string;
data?: TData;
closeOnEscapeKey?: boolean;
persistOnNavigate?: boolean;
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 stick with closeOnNavigate? That way it will be consistent with corresponding popover property

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My original thought as well. The reason I went this direction instead is because we close on navigate in every other case. We still want that as our default behavior.

By going this direction, the original usages can be left alone and furthermore future uses can continue to omit the property to use modals in the default behavior.

Like you, I prefer the consistency of your suggestion, but I think the use cases make this a more maintainable option.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking more, how would a modal stay persist when we navigate? If we navigate to a different page and if we don't destroy the modal, then that could lead to unintended side effects.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that is why this property was not exposed before. cc @aaron-steinfeld if you have some thoughts on this one

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I'm not a huge fan. The use case was to change query params rather than the whole modal, and I could see supporting that (and probably by default - because it would be weird to have a query param change close a modal), but we also want to be careful about a modal changing the url in the first place.

On a slightly separate note :

By going this direction, the original usages can be left alone and furthermore future uses can continue to omit the property to use modals in the default behavior.

If we proceed, I would still make it consistent - we can default the value to either true or false, we don't have to (and shouldn't anyway) rely on the falsiness of a missing value.

Comment on lines +67 to +69
if (!modalContainerData.config.persistOnNavigate) {
popover.closeOnNavigation();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious. whats the usecase and how would this work in practice? when we show a modal, usually the backdrop is non-interactable. How would a navigation get triggered?

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.

None yet

4 participants