Skip to content

Commit

Permalink
Merge pull request #1611 from DissNik/3.x-sticky-buttons
Browse files Browse the repository at this point in the history
fix sticky buttons
  • Loading branch information
lee-to authored Mar 9, 2025
2 parents 0c07280 + 4ad69f7 commit a32bc16
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/UI/resources/js/Components/TableBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,25 @@ export default (
*
*/
updateStickyColumns() {
const trs = Array.from(this.table?.querySelectorAll('tr') || [])
const trs = [];
if (this.table) {
if (this.table.tBodies.length > 0) {
trs.push(...Array.from(this.table.tBodies[0].rows));
}
if (this.table.tHead) {
trs.push(...Array.from(this.table.tHead.rows));
}
if (this.table.tFoot) {
trs.push(...Array.from(this.table.tFoot.rows));
}
}
const trsWithStickyCol = trs.filter(tr => tr.querySelector(`.${this.stickyColClass}`))
if (trsWithStickyCol.length < 1) return

const refRow = trsWithStickyCol[0]
const refRowCells = Array.from(refRow.querySelectorAll('td,th') || [])
const refRowCells = Array.from(refRow.children).filter(child =>
child.tagName === 'TD' || child.tagName === 'TH'
);
const otherRows = trs.filter(tr => tr !== refRow)

const stickyCells = refRowCells.filter(cell => cell.classList.contains(this.stickyColClass))
Expand Down Expand Up @@ -365,7 +378,9 @@ export default (

// Apply the same values to TD cells
otherRows.forEach(row => {
const cells = row.querySelectorAll('td')
const cells = Array.from(row.children).filter(child =>
child.tagName === 'TD' || child.tagName === 'TH'
);
stickyCells.forEach(stCell => {
const index = refRowCells.indexOf(stCell)
const cell = cells[index]
Expand Down

0 comments on commit a32bc16

Please sign in to comment.