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 bug in narratives with filter changes #1883

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

jameshadfield
Copy link
Member

Noticed while debugging #1879. Minimal narrative to reproduce:

---
title: Test narrative for bugs when changing filters during narratives
authors:
  - James Hadfield
dataset: "http://localhost:4000/flu/seasonal/h3n2/ha/2y?d=tree&f_clade_membership=2a.1"
date: October 2024
abstract:
    Opening page defines a filter query to clade 2a.1
---


# [Flu dataset (filtered)](http://localhost:4000/flu/seasonal/h3n2/ha/2y?d=tree&f_clade_membership=2a.1)

Initial slide (identical to title slide) is filtered to clade 2a.1


# [Flu dataset (no filters)](http://localhost:4000/flu/seasonal/h3n2/ha/2y?d=tree)

Tree should no longer be filtered. If you load this slide directly it's ok, but if you load the previous slide and move to this one the filter query is not applied.

Reason: When we constructed the initial controls state we essentially did

controls.defaults = {
    filters: {}
},
controls.filters = controls.defaults.filters

and thus changing the current filter would also change the default. For narratives we need to be able to reset the default state, and we ended up keeping the current state.

When we constructed the initial controls state we essentially did
```
controls.defaults = {
    filters: {}
},
controls.filters = controls.defaults.filters
```
and thus changing the current filter would also change the default. For
narratives we need to be able to reset the default state, and since each
value pointed to the same reference we ended up keeping the current
state.
@jameshadfield jameshadfield added the bug Something isn't working label Nov 4, 2024
@nextstrain-bot nextstrain-bot temporarily deployed to auspice-james-narrative-xpdqbz November 4, 2024 23:46 Inactive
@jameshadfield jameshadfield merged commit 2cf13e3 into master Nov 5, 2024
27 checks passed
@jameshadfield jameshadfield deleted the james/narratives-fix branch November 5, 2024 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants