Only request gadget mappings when "Show reduction" is on

Open Beginner friendly
#429 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, playwright
Domain
frontend, testing

Research direction

Read components/widgets/VisualizationLogic.js and components/pageblocks/VisualizeRowReact.js to trace gadget fetching and the two switches. Follow the request watching pattern in #390's tests, then run the relevant Playwright test. Done when gadgets cannot be enabled without Show reduction, disabling Show reduction turns gadgets off, and the gadgets request is sent once when both are on.

Written by the indexing model from the issue text.

Description

good first issue

Follow-up from the review of #390 (raised by @c-hayCodes when approving).

Why

Gadgets belong to a reduction, not to a problem on its own. The request is ProblemProvider/gadgets?reduction=<chosen reduction>, and it answers "which source pieces became which target pieces". With "Show reduction" off, the target pieces (reductionToIds) aren't on screen, so what's left is a grouping of the main picture's pieces that changes with the reduction dropdown even though no reduction is shown. That is confusing, so the gadget map should go with the reduction.

What happens now

The gadget map (and the solve and reduce requests behind it) is fetched when either "Show reduction" or "Highlight gadgets" is on: wantGadgets = visualizationState.reductionOn || visualizationState.gadgetsOn in components/widgets/VisualizationLogic.js. So turning on "Highlight gadgets" by itself still sends those requests.

What to change

  1. In components/widgets/VisualizationLogic.js, fetch the gadget map only when "Show reduction" is on (wantGadgets = visualizationState.reductionOn).
  2. In components/pageblocks/VisualizeRowReact.js, make "Highlight gadgets" depend on "Show reduction": disable the switch while "Show reduction" is off, and turn it off when "Show reduction" is turned off.
  3. Add a Playwright test: with "Show reduction" off, turning on "Highlight gadgets" isn't possible and no ProblemProvider/gadgets request is sent. With both on, the request is sent once. #390's tests show how to watch requests.

Out of scope

Changing how the renderers highlight (they also color the hovered piece without the gadget map) is #430.

Dominant language
JavaScript
Stars
3
Forks
18
Avg merge
1d 15h
Merged PRs (30d)
27

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

  • Ships a Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

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 ReduxISU/Redux_GUI

All issues in ReduxISU/Redux_GUI

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.