Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lassoEnd with no point in selection does not publish deselect event #132

Closed
insertmike opened this issue May 3, 2023 · 2 comments · Fixed by #133
Closed

lassoEnd with no point in selection does not publish deselect event #132

insertmike opened this issue May 3, 2023 · 2 comments · Fixed by #133
Labels
bug Something isn't working

Comments

@insertmike
Copy link
Contributor

After selecting an empty region with the lasso, the select event is always triggered, with 0 points array:

  const select = (pointIdxs, { merge = false, preventEvent = false } = {}) => {

Internally, the function clears the selectionPoints state and triggers the deselect method:

selectedPoints = pointIdxsArr;
if (currSelectedPoints.length > 0 && selectedPoints.length === 0) {
   deselect({ preventEvent });
   return;
}

In the deselect method, the lassoClearEvent checks goes through, which clears the lasso, but since the selectedPoints array have been updated in the select method to have a length of 0, the pubSub.publish('deslect') event is never triggered.

  const deselect = ({ preventEvent = false } = {}) => {
    if (lassoClearEvent === LASSO_CLEAR_ON_DESELECT) lassoClear();
    if (selectedPoints.length) {
      if (!preventEvent) pubSub.publish('deselect');
      selectedPointsConnectionSet.clear();
      setPointConnectionColorState(selectedPoints, 0);
      selectedPoints = [];
      selectedPointsSet.clear();
      draw = true;
    }
  };

Creating a PR now.

@flekschas flekschas added the bug Something isn't working label May 4, 2023
@flekschas
Copy link
Owner

After selecting an empty region with the lasso, the select event is always triggered, with 0 points array:

This is not true. Selecting an empty region does not trigger a select event because of https://github.com/flekschas/regl-scatterplot/blob/master/src/index.js#L704-L707.

But I think I know what mean. After having select some number of points and then lassoing to select no points will clear the selection but does not trigger a deselect event.

@flekschas
Copy link
Owner

Closing this as #133 is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants