Skip to content

feat: add context to register and trigger bank chart controls#258

Open
amliu-jumptrading wants to merge 5 commits intomainfrom
amliu/buffer-chart-control
Open

feat: add context to register and trigger bank chart controls#258
amliu-jumptrading wants to merge 5 commits intomainfrom
amliu/buffer-chart-control

Conversation

@amliu-jumptrading
Copy link
Collaborator

@amliu-jumptrading amliu-jumptrading commented Feb 25, 2026

  • added a context for registering and triggering chart controls
  • register the bundle toggle group filter with the context
  • add tooltip to the distribution bar to provide more insight on the value of thinner bars
  • add affordance for clickable distribution bars (only bundle currently)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a context-based control system to enable interaction between distribution bar charts and bank chart filters. When users click on a distribution bar (specifically the Bundle/Other bars in Income Distribution), the corresponding filter in the bank chart controls is automatically triggered and focused, with visual feedback via tooltips.

Changes:

  • Implemented ChartControlsContext with a ref-based callback registry pattern for registering and triggering chart controls
  • Made distribution bars interactive with click handlers, tooltips, and hover effects
  • Converted ToggleGroupControl from uncontrolled to controlled component with ref forwarding for programmatic focus
  • Added visual feedback (tooltip with highlight, focus states, scroll-into-view) when controls are triggered externally

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/features/SlotDetails/index.tsx Wraps SlotDetails components with ChartControlsProvider
src/features/SlotDetails/ChartControlsContext.tsx Defines types and creates context for chart controls system
src/features/SlotDetails/ChartControlsProvider.tsx Implements provider with ref-based callback registry
src/features/SlotDetails/DetailedSlotStats/FeeSection/IncomeByBundle.tsx Adds click handler to trigger bundle filter control
src/features/SlotDetails/DetailedSlotStats/FeeSection/DistributionBars.tsx Makes bars interactive with click support, tooltips, and conditional styling
src/features/SlotDetails/DetailedSlotStats/FeeSection/distributionBars.module.css Adds clickable styles with hover effects, removes overflow:hidden
src/features/Overview/SlotPerformance/TransactionBarsCard/ChartControls/useChartControl.ts Custom hook for registering controls and managing tooltip state
src/features/Overview/SlotPerformance/TransactionBarsCard/ChartControls/index.tsx Implements bundle control registration, focus handling, and scroll behavior
src/features/Overview/SlotPerformance/TransactionBarsCard/ChartControls/ToggleGroupControl.tsx Converts to controlled component with ref forwarding and tooltip support
src/features/Overview/SlotPerformance/TransactionBarsCard/ChartControls/toggleGroupControl.module.css Adds tooltip-triggered state styling and improves focus states
src/features/Overview/SlotPerformance/TransactionBarsCard/ChartControls/chartControl.module.css Adds tooltip styling for chart controls
src/colors.ts Adds slotDetailsChartControlsTriggered color for visual feedback

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@asuzuki-jumptrading asuzuki-jumptrading left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very clever way to not keep the filter values in the context! Nice work :D

Copy link
Collaborator

@atsai-jumptrading atsai-jumptrading left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much cleaner! 🧼

{onItemClick ? (
<Flex
asChild
className={styles.clickable}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to make our own clickable styling? Can we not use radix button with ghost variant or the reset component?

const closeTooltip = useCallback(() => setIsTooltipOpen(false), []);

useEffect(() => {
const cleanup = registerControl(key, (value) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could just return registerControl

) {
const { registerControl } = useContext(ChartControlsContext);
const updateRef = useRef(update);
useEffect(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can just do this in the render without the useEffect, actually slower updating within the useEffect

hasMinTextWidth,
}: ToggleGroupControlProps<T>) {
const [value, setValue] = useState(defaultValue);
export interface ToggleGroupControlHandle<T extends string> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think convention is to just call it by componentRef, as in ToggleGroupControlRef

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.

4 participants