Skip to content

Conversation

@rrahir
Copy link
Collaborator

@rrahir rrahir commented Dec 3, 2025

The method adaptRange was originally designed for each plugin to update their own ranges, whithout having to manually react to the different commands that alter the sheets structure.

We have abused the system when we introduced the spreadsheet pivots to allow the modification of a pivot dataset (which is stored in PivotCorePlugin) from another entry point SpreadsheetPivotCorePlugin) by dispatching an UPDATE_PIVOT command but there are some side effects that we did not account for, the dispatched command is forwarded to EVERY other plugin. Meaning that during an adaptRange, which should only concern a specific plugin, we end up notifying a change to the whole core/coreview stack.

This revision removes the access to 'dispatch' during the handling of adaptRange so we ensure that the changes are kept locally.

Task: 5380747

Description:

description of this task, what is implemented and why it is implemented that way.

Task: TASK_ID

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 Dec 3, 2025

Pull request status dashboard

@rrahir rrahir force-pushed the 18.0-prevent-dispatch-in-adapt-range-rar branch from da92f16 to 920785b Compare December 3, 2025 11:40
Copy link
Contributor

@hokolomopo hokolomopo left a comment

Choose a reason for hiding this comment

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

👋

Comment on lines 55 to 60
// Bind adaptRanges to a version of `this` where `dispatch` always throws
const thisWithThrowingDispatch = Object.create(this);
thisWithThrowingDispatch.dispatch = () => {
throw new Error("dispatch is not allowed in adaptRanges context");
};
range.addRangeProvider(this.adaptRanges.bind(thisWithThrowingDispatch));
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a test for this 🙂

And maybe it should be the responsibility of the range plugin, rather than every other plugin ? With a boolean isAdaptingRange or something that would throw on a command handle ... not sure tho.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

And maybe it should be the responsibility of the range plugin

I thought about it as well, I liked that implementation a bit but the shallow copy might not be the brightest idea. Maybe others will have a strong opinion about this?

@rrahir rrahir force-pushed the 18.0-prevent-dispatch-in-adapt-range-rar branch from 920785b to 0674451 Compare December 5, 2025 11:07
Copy link
Collaborator

@LucasLefevre LucasLefevre left a comment

Choose a reason for hiding this comment

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

robodoo r+

@robodoo
Copy link
Collaborator

robodoo commented Dec 9, 2025

@rrahir @LucasLefevre because this PR has multiple commits, I need to know how to merge it:

  • merge to merge directly, using the PR as merge commit message
  • rebase-merge to rebase and merge, using the PR as merge commit message
  • rebase-ff to rebase and fast-forward

@LucasLefevre
Copy link
Collaborator

oups, I didn't see the second commit.

I'm ok with the second implementation

@rrahir rrahir force-pushed the 18.0-prevent-dispatch-in-adapt-range-rar branch from 0674451 to 32f35b3 Compare December 9, 2025 18:18
The method `adaptRange` was originally designed for each plugin to
update their own ranges, whithout having to manually react to the
different commands that alter the sheets structure.

We have abused the system when we introduced the spreadsheet pivots to
allow the modification of a pivot dataset (which is stored in
PivotCorePlugin) from another entry point `SpreadsheetPivotCorePlugin`)
by dispatching an UPDATE_PIVOT command but there are some side effects
that we did not account for, the dispatched command is forwarded to
EVERY other plugin. Meaning that during an adaptRange, which should only
concern a specific plugin, we end up notifying a change to the whole
core/coreview stack.

This revision removes the access to 'dispatch' during the handling of
`adaptRange` so we ensure that the changes are kept locally.

Task: 5380747
@rrahir rrahir force-pushed the 18.0-prevent-dispatch-in-adapt-range-rar branch from 32f35b3 to eab32b3 Compare December 9, 2025 18:19
@rrahir
Copy link
Collaborator Author

rrahir commented Dec 11, 2025

@LucasLefevre it's updated :)

Copy link
Collaborator

@LucasLefevre LucasLefevre left a comment

Choose a reason for hiding this comment

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

robodoo r+

robodoo pushed a commit that referenced this pull request Dec 11, 2025
The method `adaptRange` was originally designed for each plugin to
update their own ranges, whithout having to manually react to the
different commands that alter the sheets structure.

We have abused the system when we introduced the spreadsheet pivots to
allow the modification of a pivot dataset (which is stored in
PivotCorePlugin) from another entry point `SpreadsheetPivotCorePlugin`)
by dispatching an UPDATE_PIVOT command but there are some side effects
that we did not account for, the dispatched command is forwarded to
EVERY other plugin. Meaning that during an adaptRange, which should only
concern a specific plugin, we end up notifying a change to the whole
core/coreview stack.

This revision removes the access to 'dispatch' during the handling of
`adaptRange` so we ensure that the changes are kept locally.

closes #7603

Task: 5380747
Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
@robodoo robodoo closed this Dec 11, 2025
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.

4 participants