-
Notifications
You must be signed in to change notification settings - Fork 69
[FIX] CorePlugins: Prevent dispatch during adaptRange #7603
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
Conversation
da92f16 to
920785b
Compare
hokolomopo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋
src/plugins/core_plugin.ts
Outdated
| // 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)); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
920785b to
0674451
Compare
LucasLefevre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
robodoo r+
|
@rrahir @LucasLefevre because this PR has multiple commits, I need to know how to merge it:
|
|
oups, I didn't see the second commit. I'm ok with the second implementation |
0674451 to
32f35b3
Compare
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
32f35b3 to
eab32b3
Compare
|
@LucasLefevre it's updated :) |
LucasLefevre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
robodoo r+
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]>

The method
adaptRangewas 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
adaptRangeso 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