Skip to content

feat(table): allow sort by column#8353

Open
luka-nextcloud wants to merge 1 commit intomainfrom
sort-by-column
Open

feat(table): allow sort by column#8353
luka-nextcloud wants to merge 1 commit intomainfrom
sort-by-column

Conversation

@luka-nextcloud
Copy link
Copy Markdown
Contributor

@luka-nextcloud luka-nextcloud commented Mar 17, 2026

📝 Summary

🚧 TODO

  • ...

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests
  • Documentation (README or documentation) has been updated or is not required

@luka-nextcloud
Copy link
Copy Markdown
Contributor Author

🖼️ Screenshots

demo.webm

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 85.91549% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/nodes/Table/TableHeaderView.vue 0.00% 6 Missing ⚠️
src/nodes/Table/Table.js 93.65% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@max-nextcloud
Copy link
Copy Markdown
Collaborator

@luka-nextcloud Thanks a lot! That looks really great. I'll take a look at the code. Could you rebase and npm run prettier:fix on the branch to make prettier happy?

Thanks!

Copy link
Copy Markdown
Collaborator

@max-nextcloud max-nextcloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All in all looks good.

I think it would be nice to not move the cursor around to change the sort order. I added some more detailed comments explaining how I think this would be feasible.

Signed-off-by: Luka Trovic <luka@nextcloud.com>
Comment on lines +75 to +99
const getSortableCellText = (cell) => cell.textContent.trim()

const isTableCellType = (node) =>
node?.type?.name === 'tableCell' || node?.type?.name === 'tableHeader'

const resolveTableCellFromPosition = (doc, position) => {
const tryResolve = (pos) => {
if (typeof pos !== 'number' || pos < 0 || pos > doc.content.size) {
return null
}
const $pos = doc.resolve(pos)
for (let depth = $pos.depth; depth > 0; depth -= 1) {
if (isTableCellType($pos.node(depth))) {
return { $cell: $pos, cellDepth: depth }
}
}
return null
}

return (
tryResolve(position)
|| tryResolve(typeof position === 'number' ? position + 1 : position)
)
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Table: allow to sort by column

2 participants