[FIX] borders: merged cell loses adjacent border after import #7607
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Description:
Steps to reproduce:
Save the file, close the spreadsheet, and reopen it.
On import, the following happens:
From
data.borders, we calladdBorderwith:Zone: { top: 1, left: 2, bottom: 2, right: 2 } // C2:C3
Border: { top, bottom, right, left (all thin black) }
Then we call
addBorderfor B2:B3 with:Zone: { top: 1, left: 1, bottom: 2, right: 1 } // B2:B3
Border: { top, bottom, right, left, vertical, horizontal (all thin black) }
Finally,
import()callsaddBordersToMerge(), which computes:Zone: { top: 1, left: 2, bottom: 2, right: 2 } // C2:C3
Border: { top, bottom, right } // no left
and then calls:
this.addBorder(sheetId, zone, border, /* force = */ true);The issue comes from how
forcewas handled insideaddBorder().Because
force = truefor the merge, every entry inexistingBorderSideToClearwas set totrue.Thus, when the merged zone was adjacent to B2:B3, we cleared the border on the shared edge even if the new border did not define that side (in this case, there is no
lefton the merge). As a result, the right border of B2:B3 (the edge between B and C) disappeared after reopening.We now compute
existingBorderSideToClearso that it only depends on the sides actually defined on the new border.Task: 5390397
review checklist