Skip to content

Conversation

@Abdkhan14
Copy link
Contributor

@Abdkhan14 Abdkhan14 commented Nov 21, 2025

  • This PR uses the new useChartXRangeSelection to enable range selection only in explore charts
  • Removes the old useBoxChartSelection hook
Screenshot 2025-11-21 at 11 23 04 AM

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 21, 2025
);
boxSelectOptions.clearSelection();
}, [boxSelectOptions, router]);
clearSelection();
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Falsy check fails for zero timestamp values

The condition checks if startTimestamp or endTimestamp are falsy, but since these are numeric timestamps, a value of 0 (Unix epoch) is valid yet falsy in JavaScript. This causes the function to incorrectly return early when the selection includes timestamp 0, preventing zoom functionality for that edge case. The check needs to explicitly test for null or undefined rather than relying on falsy evaluation.

Fix in Cursor Fix in Web

saveOnZoom: true,
});

const {groupName} = useWidgetSyncContext();
Copy link
Contributor

Choose a reason for hiding this comment

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

useWidgetSyncContext gets called on line 141. Can we just get the groupName from there? Unless there's a reason we need to create another context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Laser eyes 👁️‍🗨️

boxSelectOptions={boxSelectOptions}
triggerWrapperRef={triggerWrapperRef}
/>
{index === 0 ? <AttributeComparisonCTA>{widget}</AttributeComparisonCTA> : widget}
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Chart clicks clear selection unexpectedly

The ChartWrapper no longer prevents selection clearing when clicked. The old useChartBoxSelect hook checked if clicks were inside chartWrapperRef before clearing selection, but the new useChartXRangeSelection hook uses data-explore-chart-selection-region attributes instead. The ChartWrapper lacks this attribute, causing clicks on the chart to clear the selection, breaking the previous behavior where users could interact with the chart without losing their selection.

Fix in Cursor Fix in Web

Comment on lines +157 to +163
const {brush, onBrushEnd, onBrushStart, toolBox, ActionMenu} = useChartXRangeSelection({
chartRef,
deps: [props.plottables],
disabled: true,
chartsGroupName: groupName,
...props.chartXRangeSelection,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I missed this in the original PR, but it looks like useChartXRangeSelection accepts a actionMenuRenderer, and then returns the rendered component (ActionMenu) using some states within the hook.

This feels unconventional to me because the hook now handles rendering components outside of echarts as well as brush logic in echarts. I don't think this is a blocker, but would it make more sense for the hook to just return the states necessary for rendering instead? And then the parent can handle the rendering using those states? Unless there is some limitation that forces us to do it this way. Feel free to address in a follow up if necessary!

@Abdkhan14 Abdkhan14 merged commit c8b16e3 into abdk/useChartXrangeSelection Nov 24, 2025
45 checks passed
@Abdkhan14 Abdkhan14 deleted the abdk/explore-attr-new-hook-usag branch November 24, 2025 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants