Fix event list filter bar: canonical event types + disable while loading#291
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 distinctevent_typemeta 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'];onEventsController, 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_typesfrom 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.service_body/categories/tagsare unchanged — still legitimately data-derived from the in-scope events in the same loop; only theevent_typesbranch changed.event_typesthe server returns, so no consumer change was needed. TheEventFilters.jshide-when-empty branch is left as-is; it simply never fires forevent_typenow.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.jsnow threads its existingloadingflag into<EventFilters disabled={loading} />(local prop pass-through, no new global state).EventFilters.jsacceptsdisabledand gatesonToggle/onClear; the pills, option buttons, and clear button get the nativedisabledattribute, the container getsaria-busy+ anis-disabledclass, andpublic.cssgreys the bar (opacity: .55,cursor: not-allowed).loadingis 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 buildcompiles both bundles cleanly.includes/Rest/EventsController.php; the onlycomposer lintfindings are pre-existing style nits inmayo-events-manager.php(unrelated to this PR).readme.txt(one entry per fix, no version bump).