Selecting a language inside an instrument preview switches the app language and closes the preview on Manage Group

Open
#1,946 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
react, tailwindcss, typescript
Domain
frontend, web-dev

Research direction

Start in apps/web/src/components/InstrumentPreviewDialog/InstrumentPreviewDialog.tsx around lines 93-99, where InstrumentRenderer gets no language prop, then follow useInstrumentLanguage to see how changeContentLanguage binds to the global changeLanguage. Next, check useInstrumentInfoQuery and the queryKey in apps/web/src/routes/_app/group/manage.tsx (lines 854-870 and 976-987) to see why refetching unmounts ManageGroupForm. Done means preview language changes stay local and the dialog stays open while the query refetches.

Written by the indexing model from the issue text.

Description

Area: Web Bug Difficulty: Low Priority: Low

InstrumentPreviewDialog (apps/web/src/components/InstrumentPreviewDialog/InstrumentPreviewDialog.tsx:93-99) renders InstrumentRenderer with no language prop. useInstrumentLanguage(undefined) therefore binds changeContentLanguage to libui's global changeLanguage, so switching languages from inside a previewed interactive instrument (its "Select Language" screen, its toolbar language toggle, or a changeLanguage event from the iframe) switches the whole web app's interface language.

On /group/manage (apps/web/src/routes/_app/group/manage.tsx:854-870, 976-987), useInstrumentInfoQuery includes resolvedLanguage in its queryKey. Switching to an uncached language sets instrumentInfoQuery.data to undefined while refetching, which makes data null and causes WithFallback to unmount ManageGroupForm (where previewItem state lives), closing the open InstrumentPreviewDialog immediately.

Reproduce

  1. Open /group/manage in English.
  2. Click the preview icon on a bilingual interactive instrument (or a series containing one) with enableLanguageSelect: true or enableLanguageToggle: true, click Preview Form, and click Begin.
  3. Pick Français on the "Select Language" screen (or from the toolbar language toggle).

Actual: the entire web interface switches to French and the preview dialog unmounts and closes while useInstrumentInfoQuery refetches for fr.
Expected: the preview stays open (and language switches inside a preview stay local to the preview, or ManageGroupForm keeps previous instrumentInfoQuery data while refetching).

Dominant language
TypeScript
Stars
119
Forks
19
Avg merge
1d 18h
Merged PRs (30d)
60

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DouglasNeuroInformatics/OpenDataCapture

All issues in DouglasNeuroInformatics/OpenDataCapture

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.