Skip to content

[FIX] selection: allow to de-select a zone #6125

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rmbh-odoo
Copy link
Contributor

Description:

Before this pr:

  • Ctrl+Click on a selected cell had no effect.
  • Users could add to the selection, but couldn't remove cells or zones.

Issue Example:

  1. Select range A1:C3.
  2. Ctrl+Click on B2.
  3. Expected: Selection splits into A1:C1, A2, C2, A3:C3.
  4. Previously, Ctrl+Click did not deselect B2.

After this pr:

  • Ctrl+Click on a selected cell now removes it.
  • The selection splits into separate zones as needed.

Technical Changes:

  • UpdateSelection is now triggered on mouseup, allowing precise detection of Ctrl+Click behavior.
  • The selection logic removes the zone from any existing selection zones.
  • Splits overlapping zones into non-overlapping parts.

Task: 4647187

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_t("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

@robodoo
Copy link
Collaborator

robodoo commented Apr 17, 2025

Pull request status dashboard

const anchor = event.anchor;
let zones: Zone[] = [];
let anchor = event.anchor;
let zones: Zone[] = [...this.gridSelection.zones];
Copy link
Collaborator

Choose a reason for hiding this comment

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

so you make a change on the fly and use the "updateSelection" after a previous event to 'fix' things?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the current flow, all events directly update gridSelection.zones on mouse down and drag. updateSelection is triggered after the mouse up event to correct the selection by checking if the zone already exists or overlaps.

In GSheet, zones are updated only on mouse up to avoid redundant updates during drag. On mouse up, updateSelection compares anchor.zone with existing gridSelection.zones: if present, it removes it; if overlapping, it splits; otherwise, it adds the new zone.
Let me know which approach we should go with.

@rmbh-odoo rmbh-odoo force-pushed the master-imp-allow-to-de-select-zone-rmbh branch from f53a3dd to c20c185 Compare May 5, 2025 09:24
Before this commit:
- Ctrl+Click on a selected cell had no effect.
- Users could add to the selection but couldn't remove cells or zones.

Issue Example:
1. Select range A1:C3.
2. Ctrl+Click on B2.
3. Expected: Selection splits into A1:C1, A2, C2, A3:C3.
4. Previously, Ctrl+Click did not deselect B2.

After this commit:
- Ctrl+Click on a selected cell now removes it.
- The selection splits into separate zones as needed.

Technical Changes:
- UpdateSelection is now triggered on mouseup.
- The selection logic removes the zone from any existing selection zones.
- Splits overlapping zones into non-overlapping parts.

Task: 4647187
@rmbh-odoo rmbh-odoo force-pushed the master-imp-allow-to-de-select-zone-rmbh branch from c20c185 to f2f9ea1 Compare May 9, 2025 06:41
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.

3 participants