-
Notifications
You must be signed in to change notification settings - Fork 60
[FIX] selection: prevent partial move of table rows with headers #6760
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
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.
👋
Please update the spec of the task in Odoo, without reading all the chatter it isn't clear that you're not doing point B 🙂
b0e7f83
to
faa8eba
Compare
9acf943
to
17cd172
Compare
src/plugins/ui_stateful/selection.ts
Outdated
return CommandResult.Success; | ||
} | ||
|
||
private isMovingTableHeader(sheetId: UID, selectedRows: number[]): boolean { |
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.
private isMovingTableHeader(sheetId: UID, selectedRows: number[]): boolean { | |
private isMovingTableHeader(sheetId: UID, movingRows: HeaderIndex[]): boolean { |
src/plugins/ui_stateful/selection.ts
Outdated
return false; | ||
} | ||
|
||
const headerRowEnd = top + config.numberOfHeaders; |
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.
const headerRowEnd = top + config.numberOfHeaders; | |
const headerRowEnd = top + config.numberOfHeaders - 1; |
then check <=
src/plugins/ui_stateful/selection.ts
Outdated
return false; | ||
} | ||
|
||
const isTablePartiallySelected = range(top, bottom + 1).some((r) => !selectedRowSet.has(r)); |
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.
since the spec and commit message hint that we only allow the move either if:
- we don't touch the headers
- we move the whole table as a whole
i would consider writing the code to reflect this formulation and not the opposite (as it is now)o
i think it'd be clearer and easier to name the steps/variables
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.
I’ve updated the code to reflect that logic, please have a look :)
Steps to reproduce: - Create a table with headers - Select some rows including the header row, but not the whole table - Try to move the selected rows Before this commit: Partial moves of rows including headers were allowed, which could break the table structure or leave orphaned headers. After this commit: Row moves are allowed only if the headers are not included, or if the entire table (including headers) is selected. Task: 4862731
17cd172
to
b4aa672
Compare
Nice, thanks for the update :) I think it's clearer this way robodoo r+ |
Description:
Steps to reproduce
Current behavior
The move is allowed even when only part of the table (including headers) is selected.
This results in broken table structure or orphaned headers.
Desired behavior after PR is merged
Row moves are allowed only if:
Task: 4862731
review checklist