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] FigureComponent: Stop Ctrl+A propagation #4091

Closed

Conversation

dhrp-odoo
Copy link
Contributor

@dhrp-odoo dhrp-odoo commented Apr 17, 2024

Description:

Previously, when a figure was selected, And pressing CTRL + A would select all rows and columns in the sheet, and pressing the Delete key would delete the selected figure. This occurred because all key events were bubbling up to the grid component.

This PR stops the propagation for the Ctrl+A key event in the figure component.

Task: : 3863300

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, 2024

@dhrp-odoo dhrp-odoo force-pushed the 16.0-fix-only-propagate-ctrl-y-z-figure-component-dhrp branch 5 times, most recently from 65184a8 to 86a50d8 Compare April 26, 2024 09:47
break;
case "Ctrl+Y":
case "Ctrl+Z":
// Allow the event to bubble to the grid only if Ctrl+Y or Ctrl+Z is pressed
Copy link
Collaborator

Choose a reason for hiding this comment

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

since #1803 we try an approach where every single component is responsible of their own action and do not rely on their parent potential reaction.

I would rather reimplement the call to REQUEST_UNDO/REDO (or maybe have a function defined in the spreadsheet env ) and call it explicitely

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rrahir, I believe I fixed this issue similarly in the initial PR #3678. However, I recall @hokolomopo advised me to allow events to propagate up the grid. Here is the discussion: Link. Perhaps, I will explore the option of reverting back to the previous implementation.

Copy link
Collaborator

@rrahir rrahir May 14, 2024

Choose a reason for hiding this comment

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

I wrote a message on the PR and will try to bring this discussion up on monday with the whole team present ;-) Your approach is not worse than it was before but I fear we took some liberties that we shouldn't have and now is as good time as any to correct things. Let's keep this PR on hold until we discuss this so you avoid doing the same work twice.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We still haven't decided exactly how to handle things but I would like to follow this commit idea : 3660bf2#diff-91190cae1bee7c5780c36f202f34ede615a061931ff957bf339ba10eee08f9ee which was to simply handle what you should leave the other behaviours alone. This means that you should not stop the propagation by default but only if you handle the shortcut.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rrahir, Changes made!

This function is used to convert a KeyboardEvent to a string that
represents the shortcut that was pressed.

Task: 3863300
Previously, when a figure was selected, And pressing CTRL + A would
select all rows and columns in the sheet, and pressing the Delete key
would delete the selected figure. This occurred because all key events
were bubbling up to the grid component.

This commit stops the propagation for the Ctrl+A key event in the figure
component.

Task: 3863300
@dhrp-odoo dhrp-odoo changed the title [FIX] FigureComponent: only propagate CTRL + Y/Z [FIX] FigureComponent: Stop Ctrl+A propagation May 27, 2024
@dhrp-odoo dhrp-odoo force-pushed the 16.0-fix-only-propagate-ctrl-y-z-figure-component-dhrp branch from 86a50d8 to 929c67e Compare May 27, 2024 12:46
@@ -212,6 +214,21 @@ export class FigureComponent extends Component<Props, SpreadsheetChildEnv> {
ev.preventDefault();
ev.stopPropagation();
break;
case "Ctrl+A":
// Maybe in the future we will implement a way to select all figures
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@rrahir
Copy link
Collaborator

rrahir commented May 27, 2024

@robodoo rebase-ff r+

@dhrp-odoo Thanks a lot ! :)

robodoo pushed a commit that referenced this pull request May 27, 2024
This function is used to convert a KeyboardEvent to a string that
represents the shortcut that was pressed.

Task: 3863300
Part-of: #4091
robodoo pushed a commit that referenced this pull request May 27, 2024
Previously, when a figure was selected, And pressing CTRL + A would
select all rows and columns in the sheet, and pressing the Delete key
would delete the selected figure. This occurred because all key events
were bubbling up to the grid component.

This commit stops the propagation for the Ctrl+A key event in the figure
component.

closes #4091

Task: 3863300
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
@robodoo
Copy link
Collaborator

robodoo commented May 27, 2024

Merge method set to rebase and fast-forward.

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.

None yet

4 participants