Skip to content

Fix event list filter bar: canonical event types + disable while loading#291

Merged
dgershman merged 2 commits into
mainfrom
feature/mayo-290-filter-bar-fixes
Jun 27, 2026
Merged

Fix event list filter bar: canonical event types + disable while loading#291
dgershman merged 2 commits into
mainfrom
feature/mayo-290-filter-bar-fixes

Conversation

@dgershman

Copy link
Copy Markdown
Contributor

Closes #290

Two unrelated filter-bar bugs, fixed as two atomic commits a reviewer can land/revert independently.

Fix #1 — canonical Event Type facet (commit dc4ac1c)

The Event Type filter was data-derived: EventsController::get_events_facets() collected distinct event_type meta values from the in-scope events, so any type with no currently scheduled events silently dropped out of the filter.

Approach: option (a) — the canonical list is hardcoded in PHP as a const EVENT_TYPES = ['Service', 'Activity', 'Celebration']; on EventsController, with a comment cross-referencing the three JS dropdowns that already define the same enum (EventForm.js, Settings.js, EventBlockEditorSidebar.js). get_events_facets() now seeds $event_types from that constant instead of scanning event meta.

I deliberately did not extract a shared JS constant (option b): each JS consumer wraps its labels in literal __('Service', …) calls for POT string extraction; swapping those for a variable (__(type, …)) would break i18n extraction, so a shared module wouldn't reduce code and would risk a translation regression.

  • Celebration now renders in the Event Type filter even on a window with zero Celebration events (the facet is the fixed enum, no longer scanned from data).
  • service_body / categories / tags are unchanged — still legitimately data-derived from the in-scope events in the same loop; only the event_types branch changed.
  • The frontend already renders whatever event_types the server returns, so no consumer change was needed. The EventFilters.js hide-when-empty branch is left as-is; it simply never fires for event_type now.

Fix #2 — disable filters while loading (commit e0bc1f3)

Toggling a filter while a fetch was in flight could interleave with the response and corrupt the selection.

  • EventList.js now threads its existing loading flag into <EventFilters disabled={loading} /> (local prop pass-through, no new global state).
  • EventFilters.js accepts disabled and gates onToggle / onClear; the pills, option buttons, and clear button get the native disabled attribute, the container gets aria-busy + an is-disabled class, and public.css greys the bar (opacity: .55, cursor: not-allowed).
  • Before: during a fetch you could open panels and toggle options, racing the in-flight request. After: while loading is true the bar is greyed and inert — panels won't open and option/clear clicks are no-ops — then becomes interactive again when the response lands. This disabled state is kept separate from the hide-when-empty logic.

Verification

  • npm run build compiles both bundles cleanly.
  • PHP change is in includes/Rest/EventsController.php; the only composer lint findings are pre-existing style nits in mayo-events-manager.php (unrelated to this PR).
  • Changelog updated in readme.txt (one entry per fix, no version bump).

dgershman and others added 2 commits June 27, 2026 16:41
The Event Type filter was data-derived: get_events_facets() collected
distinct event_type meta values from the in-scope events, so any type
with no currently scheduled events (e.g. Celebration) silently dropped
out of the filter. Event type is a fixed enumeration, so source the
facet from a canonical EVENT_TYPES list instead. service_body,
categories and tags remain legitimately data-derived.

Crow-Session: EA076E5A-82D5-419A-B06F-8938998A799D
Co-Authored-By: Claude <noreply@anthropic.com>
Toggling a filter while a fetch was in flight could interleave with the
response and leave the filter selection in an inconsistent state.
EventList now passes its loading flag into EventFilters, which gates
onToggle/onClear and marks the pills, options and clear button disabled
(greyed via .is-disabled / aria-busy) until the request returns.

Crow-Session: EA076E5A-82D5-419A-B06F-8938998A799D
Co-Authored-By: Claude <noreply@anthropic.com>
@dgershman
dgershman merged commit 196da80 into main Jun 27, 2026
3 checks passed
@dgershman
dgershman deleted the feature/mayo-290-filter-bar-fixes branch June 27, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant