Skip to content

fix: give each range button on the Analytics page its own action id - #40

Merged
danielmlr merged 2 commits into
mainfrom
fix/range-button-keys
Nov 23, 2026
Merged

danielmlr merged 2 commits into
mainfrom
fix/range-button-keys

Conversation

@danielmlr

Copy link
Copy Markdown
Member

The 7, 30 and 90 day buttons on the Analytics page shared the action id analytics:range. The admin renders the elements of an actions block with their action id as the React key, and has since EmDash 1.0.1, so the three buttons were three children with one key. In development React logs "Encountered two children with the same key, analytics:range" on every load of the page.

What changes

  • Each range button sends analytics:range|<days>. The range still travels in the button's value, so the handler reads it as before.
  • The plain analytics:range keeps working: the setup check's "Back to analytics" button sends it, and so does a page that was rendered before the update.
  • The per-entry page already builds its ids this way (analytics:content:view|…).

Checks

  • New test in tests/page.test.ts: every actions block of the page has distinct action ids. It fails without the fix (expected 3 to be 5).
  • tests/page-sync.test.ts now switches to 90 days through the new id, in the real sandbox; tests/plugin.test.ts keeps using the plain one.
  • pnpm typecheck, pnpm test (validate + 315 tests), pnpm build.
  • Seen in a real admin: the packed build on a fresh create-emdash@1.6.0 site with demo data, on desktop and on a phone with touch. 90, 7 and 30 days each load their range, the way back from the setup check lands on 30 days, and the console stays empty. Before the fix the same site logged the warning.

Independent of #38 and #39: it merges with either branch without a conflict.

The admin keys the elements of an actions block by their action id. The
7, 30 and 90 day buttons shared analytics:range, so React saw three
children with one key and said so in the console. Each button now sends
analytics:range|<days>; the range still travels in the value, and the
plain id keeps working for the setup check's way back and for a page
rendered before the update.
@changeset-bot

changeset-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 844aa32

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@eisbachcode/emdash-plugin-analytics Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@danielmlr
danielmlr merged commit bc69beb into main Nov 23, 2026
3 checks passed
@danielmlr
danielmlr deleted the fix/range-button-keys branch November 23, 2026 19:05
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