Stop range sliders from pushing an undo step on every input event

Open Beginner friendly
#4 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start in web/app.mjs at live() (lines 227–234), then inspect the slider handlers for Camera amount, Darken image, palette colours, Film grain and Vignette. Reuse one live() closure for each control across its input and change handlers, and apply the 80 entry cap there. Run npm test and npm run check; done when each control adds one undo entry per drag, one Ctrl+Z restores its starting value, and undo.length stays at or below 80.

Written by the indexing model from the issue text.

Description

bug good first issue

live(mutate) is meant to take one undo snapshot per edit. It keeps a snap flag in its closure, and text fields create the closure once, so it works for them. The range sliders call live(...) inline inside their handlers instead:

oninput: e => live(v => { s.camera.amount = v; })(Number(e.target.value), false),
onchange: e => live(v => { s.camera.amount = v; })(Number(e.target.value), true)

Every input event creates a fresh closure with snap = false, so every event pushes a full JSON.stringify(sb) onto undo. One drag across the Camera amount slider leaves about 20 snapshots. Ctrl+Z then steps back one slider tick at a time.

live() also never trims the stack. commit() caps it at 80 entries, but this path grows undo without limit.

Task:

  • create one live(...) per slider and reuse it in both handlers, e.g. a small range(value, mutate, opts) helper next to number() and text()
  • apply the same 80-entry cap inside live()

The affected controls are Camera amount, Darken image, Film grain, Vignette and the four palette colour pickers.

Where: web/app.mjs:227-234 (live), web/app.mjs:300-301 (camera amount, darken), web/app.mjs:421 (palette colours), web/app.mjs:432-433 (grain, vignette).

Done when: one drag across the Camera amount slider adds exactly one entry to undo, and a single Ctrl+Z returns it to its starting value (same for Darken image, Film grain, Vignette and each palette colour picker); undo.length never goes above 80.


Getting started: Node 22, no npm install needed: git clone, npm start, open http://127.0.0.1:4520 in Chrome or Edge, and run npm test and npm run check before the PR. Comment here to claim it. Questions → Discord.

Dominant language
JavaScript
Stars
42
Forks
6
Avg merge
12h 31m
Merged PRs (30d)
3

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 blixvip/GenMotion

All issues in blixvip/GenMotion

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.