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

Fix selection issues #6128

Merged
merged 16 commits into from
Jul 29, 2024
Merged

Fix selection issues #6128

merged 16 commits into from
Jul 29, 2024

Conversation

gbalint
Copy link
Contributor

@gbalint gbalint commented Jul 25, 2024

Problem:

  1. In a selected scene, dragging an element should drag the scene not the element

  2. In a selected scene, clicking on an element should select the element

  3. In a selected scene, dragging an element under the threshold not move anything, but select the element

  4. In a selected scene, cmd-dragging an element should drag the element not the scene

  5. In a selected scene, cmd-clicking an element should select the element

  6. In a selected scene, cmd-dragging an element under the drag threshold should not move anything, but select the element

Fix:
To fix 1-2-3 we need to make sure that dragging below the threshold is handled as a "click", so the selection happens on mouse up.

To fix 4-5-6 we need to make sure the cmd-mousedown already selects the element, which guarantees that the following dragging operates on the element (and not the scene)

Meanwhile, the failing tests uncovered that we have an extra bug: you can deselect a selected item if you click on a non-visible (e.g. cropped) part of it. To fix it I modified the behavior of findValidTarget in dont-prefer-selected mode: it means we should change our selection to something different if possible, but we should still not deselect it. To make this clearer I renamed don't-prefer-selected to prefer-more-specific-selection

As I fixed the tests I had to realize that our dragging helper functions are not good enough: we can specifiy modifier keys, but we can not specify separate modifier keys for the mouse down and for the mouse move events. Which is necessary because e.g. cmd changes the behavior differently in the two cases: cmd on mouse down changes how selection work, so it changes what will be dragged, while cmd on mouse move changes which strategy will be applied (cmd allows reparenting).

Manual Tests:
I hereby swear that:

  • I opened a hydrogen project and it loaded
  • I could navigate to various routes in Preview mode

Fixes #6012

Copy link
Contributor

github-actions bot commented Jul 25, 2024

Try me

Copy link

relativeci bot commented Jul 25, 2024

#13559 Bundle Size — 62.65MiB (~+0.01%).

6d893a9(current) vs 6339ece master#13540(baseline)

Warning

Bundle contains 70 duplicate packages – View duplicate packages

Bundle metrics  Change 2 changes Regression 1 regression
                 Current
#13559
     Baseline
#13540
Regression  Initial JS 45.72MiB(~+0.01%) 45.72MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 21.57% 21.55%
No change  Chunks 31 31
No change  Assets 34 34
No change  Modules 4380 4380
No change  Duplicate Modules 525 525
No change  Duplicate Code 31.64% 31.64%
No change  Packages 469 469
No change  Duplicate Packages 70 70
Bundle size by type  Change 2 changes Regression 1 regression Improvement 1 improvement
                 Current
#13559
     Baseline
#13540
Regression  JS 62.64MiB (~+0.01%) 62.64MiB
Improvement  HTML 11.16KiB (-0.33%) 11.2KiB

Bundle analysis reportBranch fix/selection-problemsProject dashboard

@gbalint gbalint marked this pull request as ready for review July 26, 2024 18:33
@gbalint gbalint merged commit 09db5c4 into master Jul 29, 2024
17 checks passed
@gbalint gbalint deleted the fix/selection-problems branch July 29, 2024 10:18
liady pushed a commit that referenced this pull request Dec 13, 2024
**Problem:**

1. In a selected scene, dragging an element should drag the scene not
the element
2. In a selected scene, clicking on an element should select the element
3. In a selected scene, dragging an element under the threshold not move
anything, but select the element

4. In a selected scene, cmd-dragging an element should drag the element
not the scene
5. In a selected scene, cmd-clicking an element should select the
element
6. In a selected scene, cmd-dragging an element under the drag threshold
should not move anything, but select the element

**Fix:**
To fix 1-2-3 we need to make sure that dragging below the threshold is
handled as a "click", so the selection happens on mouse up.

To fix 4-5-6 we need to make sure the cmd-mousedown already selects the
element, which guarantees that the following dragging operates on the
element (and not the scene)

Meanwhile, the failing tests uncovered that we have an extra bug: you
can deselect a selected item if you click on a non-visible (e.g.
cropped) part of it. To fix it I modified the behavior of
`findValidTarget` in `dont-prefer-selected` mode: it means we should
change our selection to something different if possible, but we should
still not deselect it. To make this clearer I renamed
`don't-prefer-selected` to `prefer-more-specific-selection`

As I fixed the tests I had to realize that our dragging helper functions
are not good enough: we can specifiy modifier keys, but we can not
specify separate modifier keys for the mouse down and for the mouse move
events. Which is necessary because e.g. cmd changes the behavior
differently in the two cases: cmd on mouse down changes how selection
work, so it changes what will be dragged, while cmd on mouse move
changes which strategy will be applied (cmd allows reparenting).

**Manual Tests:**
I hereby swear that:

- [x] I opened a hydrogen project and it loaded
- [x] I could navigate to various routes in Preview mode

Fixes #6012
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.

Our selection handling regressed
4 participants