Skip to content

Keep a bar's width when it is clicked in edit mode - #1

Open
alex-andreyev wants to merge 1 commit into
MarketKernel:mainfrom
alex-andreyev:fix-bar-width-on-click
Open

alex-andreyev wants to merge 1 commit into
MarketKernel:mainfrom
alex-andreyev:fix-bar-width-on-click

Conversation

@alex-andreyev

Copy link
Copy Markdown

What goes wrong

In edit mode, clicking a period's bar to select it shrinks the bar to the width of its name, while the details open on the right. The next zoom or pan draws it right again. An era pressed at its edge and an event card do the same.

Why

In edit mode claimPointer (src/app/editing.ts) takes every press on a bar, an era's edge or a card, so that it can be dragged. On release, up() cleared the element's style.transform, style.width and style.boxShadow whether or not anything had moved.

The strip sets each bar's width inline (buildBars in view.ts), and nothing in a drag sets it. Clearing it left the button only as wide as its label until the next build.

Fix

A press let go where it began is a click: up() now returns before touching the element. After a real drag it resets what the drag set (transform, box shadow), as before. The stray width reset is gone.

Test

tests/app.mjs adds a check in edit mode: a click on Apollo's bar selects it and leaves its inline width and the view unchanged. The bar is placed wholly in the part of the strip the details panel leaves free, so selecting it does not move the strip.

The check fails without the fix ("200.875px" → "") and passes with it. npm run check passes: all unit tests, 193 browser checks and 22 PWA checks.

The suite was run with TZ=UTC. Two date tests in tests/model.mjs fail in America/Los_Angeles on main as well; that is unrelated to this change.

🤖 Generated with Claude Code

In edit mode a press on a bar, an era's edge or a card is claimed for a
drag. Letting go cleared the element's inline width even when nothing had
moved, so a clicked period's bar shrank to the width of its name until the
next zoom or pan drew it again. A press let go where it began now leaves
the element as it was built.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant