Skip to content

fix(events): keep the selected property when switching events - #4419

Open
JeremieSamson wants to merge 1 commit into
umami-software:devfrom
JeremieSamson:fix/keep-property-on-event-change
Open

JeremieSamson wants to merge 1 commit into
umami-software:devfrom
JeremieSamson:fix/keep-property-on-event-change

Conversation

@JeremieSamson

@JeremieSamson JeremieSamson commented Aug 3, 2026

Copy link
Copy Markdown

Problem

In a website's Properties tab, picking a different event always clears the
selected property, even when the newly selected event exposes that very same
property.

Properties such as page, url or source are commonly attached to several
events, so comparing one property across events is a routine task. Today it
means re-selecting the property after every single switch, and the chart area
goes empty in between.

Change

handleEventChange now keeps the current property when the newly selected
event also exposes it, and clears it otherwise, which is the current behaviour.

const nextProperties = new Set<string>(
  data
    ?.filter((field: { eventName: string }) => field.eventName === value)
    .map((field: { propertyName: string }) => field.propertyName) ?? [],
);

setEventName(value);
setPropertyName(nextProperties.has(propertyName) ? propertyName : '');
setPropertyFilters([]);

Property filters are still cleared unconditionally: their values are tied to a
specific event, so carrying them over would filter on values that may not exist
for the new event.

The useEffect that reset the property on every eventName change is removed.
setEventName is only ever called from handleEventChange, so the effect was
redundant, and it would have immediately overwritten the property being kept.

How to test

  1. Open a website with at least two events sharing a property name (for example
    two events both carrying page).
  2. Go to Properties, select the first event, then select that shared
    property. The chart renders.
  3. Switch to the second event.
    • Before: the property selector is emptied and the chart disappears.
    • After: the property stays selected and the chart reloads for the new event.
  4. Switch to an event that does not expose that property: the selector is
    cleared, as before.

Checks

  • biome lint and biome format report no changes on the modified file.
  • tsc --noEmit on the full project: 0 errors.
  • vitest run: 685 tests pass. The 2 failures in AttributionPage.test.tsx are
    pre-existing on dev and unrelated to this change: the @umami/react-zen
    mock in that file does not define ZenProvider, which src/test/render.tsx
    requires. Verified by running that test file on a clean dev checkout, where
    it fails identically.
  • No test is added here: EventProperties has no test file yet, and covering it
    would mean mocking the whole chart/pivot-table tree. Happy to add one if you
    would like it in this PR.

Targeting dev, per CONTRIBUTING.md.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Selecting a different event in the Properties tab always cleared the
selected property, even when the new event exposes that same property.
Comparing one property across events is a common task (page, url, source
are often shared by several events), and it currently requires selecting
the property again after every switch.

Keep the current property when the newly selected event also exposes it,
and fall back to the previous behaviour otherwise. Property filters are
still cleared, since their values are event-specific.

The effect that reset the property on every eventName change is removed:
setEventName is only ever called from handleEventChange, so the effect was
redundant and would have overwritten the value being kept.
@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Umami Software Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Updates event-property selection so switching events preserves the selected property when the destination event exposes a property with the same name.

  • Builds the destination event’s property-name set from the loaded event-property data.
  • Retains or clears the selected property based on membership in that set.
  • Continues clearing event-specific property filters on every event switch.
  • Removes the redundant effect that previously cleared the property after every event change.

Confidence Score: 5/5

The PR appears safe to merge, with the selected property retained only when it exists on the newly selected event.

The event selector is available only after event-property data has loaded, all current event-name changes pass through the updated handler, and property filters remain cleared at the event boundary.

Important Files Changed

Filename Overview
src/app/(main)/websites/[websiteId]/events/EventProperties.tsx Event switching now conditionally retains a shared property while reliably clearing event-specific filters; no changed-code defect was identified.

Reviews (1): Last reviewed commit: "fix(events): keep the selected property ..." | Re-trigger Greptile

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