Add History Filter Feature (Fixes Issue #511)#513
Add History Filter Feature (Fixes Issue #511)#513Roaring30s wants to merge 8 commits intolivepeer:mainfrom
Conversation
|
@Roaring30s is attempting to deploy a commit to the Livepeer Foundation Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
rickstaa
left a comment
There was a problem hiding this comment.
@Roaring30s this is amazing! I do wonder if we can improve the styling a bit to make it fit more into the original explorer styling and make it more modern. Let's see if @thebeyondr can help. I also did notice the governance events are not shown.
There was a problem hiding this comment.
Pull request overview
Adds an event-type filtering UI to the Account History view so users can narrow displayed history items by transaction/event kind (Issue #511).
Changes:
- Introduces a
useHistoryFilterhook to manage selected event types, filtered results, and popover open/close behavior. - Adds a
HistoryFilterpopover component (with badge count, clear/done actions, and a scroll-close behavior). - Integrates filtering into
components/HistoryView/index.tsxby renderingfilteredEventsinstead of the full merged history.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| hooks/index.tsx | Re-exports the new useHistoryFilter hook for consumption via "hooks". |
| hooks/filter/useHistoryFilter.ts | Implements filter state + filtered list derivation + scroll-to-close behavior. |
| components/Icons/FilterIcon.tsx | Adds a small filter SVG icon used by the filter button. |
| components/HistoryView/index.tsx | Wires the filter UI into the history view and switches rendering to filteredEvents. |
| components/HistoryView/HistoryFilter.tsx | Implements the popover UI for selecting event types to filter. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const handleScroll = (event: globalThis.Event) => { | ||
| // Find the popover element by data attribute | ||
| const popoverElement = document.querySelector( | ||
| "[data-history-filter-popover]" | ||
| ); | ||
|
|
There was a problem hiding this comment.
The scroll handler does a document.querySelector('[data-history-filter-popover]') on every scroll event while the popover is open. Scroll events can fire very frequently, so this can become a hot path. Consider caching the element once when opening (or passing a ref from HistoryFilter into the hook) and reusing it inside handleScroll.
| const handleScroll = (event: globalThis.Event) => { | |
| // Find the popover element by data attribute | |
| const popoverElement = document.querySelector( | |
| "[data-history-filter-popover]" | |
| ); | |
| // Cache the popover element once while the filter is open | |
| const popoverElement = document.querySelector( | |
| "[data-history-filter-popover]" | |
| ); | |
| const handleScroll = (event: globalThis.Event) => { |
| <Flex | ||
| key={eventType} | ||
| css={{ | ||
| alignItems: "center", | ||
| cursor: "pointer", | ||
| padding: "$1", | ||
| borderRadius: "$1", | ||
| "&:hover": { | ||
| backgroundColor: "$neutral5", | ||
| }, | ||
| }} | ||
| onClick={() => onToggleEventType(eventType)} | ||
| > |
There was a problem hiding this comment.
The filter options are implemented as clickable Flex rows with a custom checkbox UI, but they don’t expose checkbox semantics (no role="checkbox", aria-checked, keyboard toggle with Space/Enter, or focus styling). This makes the filter list hard/impossible to use with keyboard and assistive tech. Use a semantic checkbox/input (or add proper ARIA roles + keyboard handlers) for each option.
| WithdrawStakeEvent: "Withdraw Stake", | ||
| WithdrawFeesEvent: "Withdraw Fees", | ||
| WinningTicketRedeemedEvent: "Winning Ticket Redeemed", | ||
| ReserveFundedEvent: "Reserve Funded", |
There was a problem hiding this comment.
EVENT_TYPE_LABELS / ALL_EVENT_TYPES omits event types that are actually rendered in the history (e.g. VoteEvent and TreasuryVoteEvent in renderSwitch). As a result, users can’t filter for votes (one of the use-cases mentioned in #511). Add missing typenames to the label map (and consider a fallback label for unknown types to avoid rendering undefined).
| ReserveFundedEvent: "Reserve Funded", | |
| ReserveFundedEvent: "Reserve Funded", | |
| VoteEvent: "Vote", | |
| TreasuryVoteEvent: "Treasury Vote", |
Overview
This PR adds a filtering system to the account history view, allowing users to filter transaction events by event type. The implementation includes a new
HistoryFiltercomponent and auseHistoryFilterhook that manages filter state and behavior.Fixes: #511
What Was Added
New Files
hooks/filter/useHistoryFilter.ts- Custom hook for managing filter state and logiccomponents/HistoryView/HistoryFilter.tsx- Filter popover componentModified Files
components/HistoryView/index.tsx- Integrated the filter component into the history viewComponent Walkthrough
HistoryFilterComponentThe
HistoryFiltercomponent renders a filter button and popover interface:Filter Button (
PopoverTrigger)Popover Content
Clear- Removes all selected filtersFilters- Title textDone- Closes the popoverposition: stickyto remain visible while scrolling through filter optionsScrollable Filter List
Styling Details
marginRight: "$3") on all screen sizes to prevent edge touchingHook Walkthrough
useHistoryFilterHookThe hook manages all filter-related state and logic:
State Management
selectedEventTypes- Array of currently selected event type stringsisFilterOpen- Boolean controlling popover visibilityEvent Type Configuration
EVENT_TYPE_LABELS- Maps GraphQL event type names to human-readable labels:BondEvent→ "Bonded"DepositFundedEvent→ "Deposit Funded"NewRoundEvent→ "Initialize Round"RebondEvent→ "Rebond"UnbondEvent→ "Unbond"RewardEvent→ "Reward"TranscoderUpdateEvent→ "Transcoder Update"WithdrawStakeEvent→ "Withdraw Stake"WithdrawFeesEvent→ "Withdraw Fees"WinningTicketRedeemedEvent→ "Winning Ticket Redeemed"ReserveFundedEvent→ "Reserve Funded"ALL_EVENT_TYPES- Array of all available event typesFiltering Logic
filteredEvents- Memoized filtered array of events__typenamewhen filters are activetoggleEventType- Adds/removes event types from selectionclearFilters- Resets all selected filtersUX Behavior
composedPath()to detect if scroll originated from within the popoverFeatures
✅ Filter events by event type
✅ Visual indicator (badge) showing number of active filters
✅ Clear all filters button
✅ Sticky header that remains visible while scrolling filter options
✅ Auto-close popover when scrolling the main page
✅ Responsive design with proper spacing on all screen sizes
Integration
The filter is integrated into the
HistoryViewcomponent:Note: First Pass Implementation
This is the first pass of the history filter feature, implemented to gather feedback on:
Additional Features Needed:
Filter Button Location:
Let me know and I can add the changes.