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 global entity selector #3963

Merged
merged 1 commit into from
Sep 17, 2024
Merged

Conversation

sophiamersmann
Copy link
Member

@sophiamersmann sophiamersmann commented Sep 16, 2024

Fixes #3931

The global entity selector manages the selection of a chart from outside by passing in its own selection object, which should take precedence over the config's selectedEntityNames.

In #3793, Grapher's updateFromObject method was updated to also change the current selection if selectedEntityNames is given. That's sensible (and is needed in the admin), but updateFromObject is also called in the constructor. If selectedEntityNames and selection both are given then selectedEntityNames always won, which broke the global entity selector (since it relies on selection being respected).

I think it's sensible to apply the passed-in selection only if it's non-empty, but this leads to funny behaviour of the global entity selector if the selection happens to be empty (e.g., http://staging-site-fix-global-entity-selector/energy/country/spain?country=). But, apparently, even before #3793, the global entity selector has behaved weirdly for empty selections (e.g., https://e7fd384b.owid.pages.dev/energy/country/spain?country=). It's not ideal, but I don't think it's too bad.

Copy link
Member Author

sophiamersmann commented Sep 16, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @sophiamersmann and the rest of your teammates on Graphite Graphite

@owidbot
Copy link
Contributor

owidbot commented Sep 16, 2024

Quick links (staging server):

Site Admin Wizard

Login: ssh owid@staging-site-fix-global-entity-selector

SVG tester:

Number of differences (default views): 0 ✅
Number of differences (all views): 0 ✅

Edited: 2024-09-16 13:52:57 UTC
Execution time: 1.25 seconds

@sophiamersmann sophiamersmann marked this pull request as ready for review September 16, 2024 14:15
Copy link
Member

@ikesau ikesau left a comment

Choose a reason for hiding this comment

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

Nice! Fixes the issue 👌

I think that the empty query param thing is only be an issue if someone gets linked to it that way.

If the user did it to themselves by unselecting the selected country, then I think they would understand why the charts aren't rendering properly.

So maybe, if you care enough, you could prune the empty ?country= query param when the page mounts, before the embedder has started doing anything, and I think that should be fine because http://staging-site-fix-global-entity-selector/energy/country/new-zealand works?

Feel free to merge without that, though 🙂

@sophiamersmann sophiamersmann force-pushed the fix-global-entity-selector branch from 7989995 to afb5731 Compare September 17, 2024 07:53
@sophiamersmann
Copy link
Member Author

sophiamersmann commented Sep 17, 2024

Yeah, that's a good suggestion, thank you, Ike! If I have time this week, I'll follow up with another PR, but I'll merge as-is for now to get the bug fixed.

Copy link
Member Author

sophiamersmann commented Sep 17, 2024

Merge activity

@sophiamersmann sophiamersmann merged commit 90212a3 into master Sep 17, 2024
21 checks passed
@sophiamersmann sophiamersmann deleted the fix-global-entity-selector branch September 17, 2024 09:46
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.

Topic-specific country profile pages don't show data for the country
3 participants