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: The bottom and right border styles do not correctly apply to cells when a merged cell is present at the end of the selection. #689

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions src/core/data_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,9 @@ function setStyleBorders({ mode, style, color }) {
ci += rows.getCellMerge(sri, ci)[1];
}
if (mode === 'bottom') {
setStyleBorder.call(this, eri, ci, { bottom: [style, color] });
ci += rows.getCellMerge(eri, ci)[1];
const ri = getMergeCellRow(rows, ci, sri, eri);
setStyleBorder.call(this, ri, ci, { bottom: [style, color] });
ci += rows.getCellMerge(ri, ci)[1];
}
}
} else if (mode === 'left' || mode === 'right') {
Expand All @@ -266,13 +267,40 @@ function setStyleBorders({ mode, style, color }) {
ri += rows.getCellMerge(ri, sci)[0];
}
if (mode === 'right') {
setStyleBorder.call(this, ri, eci, { right: [style, color] });
ri += rows.getCellMerge(ri, eci)[0];
const ci = getMergeCellColumn(rows, ri, sci, eci);
setStyleBorder.call(this, ri, ci, { right: [style, color] });
ri += rows.getCellMerge(ri, ci)[0];
}
}
}
}

function getMergeCellRow(rows, ci, sri, eri) {
for (let ri = eri; ri >= sri; ri -= 1) {
const cell = rows.getCell(ri, ci);
if (cell && cell.merge) {
const [ rn ] = cell.merge;
if (ri + rn === eri) return ri;
return eri;
}
}

return eri;
}

function getMergeCellColumn(rows, ri, sci, eci) {
for (let ci = eci; ci >= sci; ci -= 1) {
const cell = rows.getCell(ri, ci);
if (cell && cell.merge) {
const [_, cn] = cell.merge;
if (ci + cn === eci) return ci;
return eci;
}
}

return eci;
}

function getCellRowByY(y, scrollOffsety) {
const { rows } = this;
const fsh = this.freezeTotalHeight();
Expand Down