zooniverse / front-end-monorepo

A rebuild of the front-end for zooniverse.org
https://www.zooniverse.org
Apache License 2.0
104 stars 30 forks source link

Changing project language deletes work in progress #3218

Closed eatyourgreens closed 2 years ago

eatyourgreens commented 2 years ago

Package

app-project lib-classifier

Describe the bug

Client-side page transitions should preserve classifications in the global classifier store. However, if I use the drop-down language menu to navigate from /projects/nora-dot-eisner/planet-hunters-tess/classify/workflow/11235 to /projects/fr/nora-dot-eisner/planet-hunters-tess/classify/workflow/11235 (the Classify workflow page in French), the classifier deletes my annotations and starts a new classification.

To Reproduce

  1. Uncomment LocaleSwitcher in the ProjectHeader component.
  2. Build and start the project app: yarn build && yarn start:dev.
  3. Navigate to https://local.zooniverse.org:3000/projects/nora-dot-eisner/planet-hunters-tess/classify/workflow/11235
  4. Make a couple of marks on the light curve then change the language.

Expected behavior

A locale change should refresh the classifier, but otherwise shouldn't change the global store state.

Additional context

The underlying cause is this effect hook, which starts a new classification if the workflow version changes. It runs when the classifier loads but doesn't check if workflowVersion already matches classifierStore.workflows.active?.version. https://github.com/zooniverse/front-end-monorepo/blob/ad72d0134822990e0a5d483af7489b0c4db4977d/packages/lib-classifier/src/components/Classifier/Classifier.js#L64-L79

eatyourgreens commented 2 years ago

This is fixed in the Classifier component, so that classifications are preserved when the locale prop changes, but I think it still needs checking in the project app's Classify page. Work in progress will still be lost if the classifier unmounts and mounts when the page language changes.

eatyourgreens commented 2 years ago

I'm opening this again. It's fixed in the standalone classifier, but not in the project app, where navigating between different Classify pages unmounts and mounts the classifier, which can reset the store for some projects.