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

[Bug]: #text node as firstChild in <colgroup> after upgrading to Vue 3 #5695

Open
1 task done
raftx24 opened this issue Oct 2, 2024 · 2 comments
Open
1 task done
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug

Comments

@raftx24
Copy link

raftx24 commented Oct 2, 2024

Affected Packages

table

Version(s)

2.6.6

Bug Description

We recently upgraded our project from Vue.js 2 to Vue.js 3, and after the upgrade, I encountered an issue with how firstChild is handled in a element.

Specifically, the following line of code throws an error because the firstChild of the colgroup is now a #text node.

function updateColumnsOnResize(node, colgroup, table, cellMinWidth, overrideCol, overrideValue) {
  var _a;
  let totalWidth = 0;
  let fixedWidth = true;
  let nextDOM = colgroup.firstChild; // this line
  const row = node.firstChild;
  if (!row)
    return;
  for (let i = 0, col = 0; i < row.childCount; i++) {
    const { colspan, colwidth } = row.child(i).attrs;
    for (let j = 0; j < colspan; j++, col++) {
<colgroup>
  <col style="width: 25px;">
  <col style="width: 276px;">
  <col style="width: 50px;">
</colgroup>

Suggested Fix:
Replacing firstChild with firstElementChild solves the issue, as it correctly skips over the text nodes and selects the first actual element:

Browser Used

Chrome

Code Example URL

No response

Expected Behavior

When I resize column I shouldn't get error

@tiptap_extension-table.js?v=b69cc675:1377 Uncaught TypeError: Cannot read properties of undefined (reading 'width')
    at updateColumnsOnResize (@tiptap_extension-table.js?v=b69cc675:1377:27)
    at displayColumnWidth (@tiptap_extension-table.js?v=b69cc675:1635:3)
    at move (@tiptap_extension-table.js?v=b69cc675:1548:7)

Additional Context (Optional)

No response

Dependency Updates

  • Yes, I've updated all my dependencies.
@raftx24 raftx24 added Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug labels Oct 2, 2024
@nperez0111
Copy link
Contributor

I would take a PR to resolve this

@raftx24
Copy link
Author

raftx24 commented Oct 3, 2024

@nperez0111 I create a PR to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug
Projects
None yet
Development

No branches or pull requests

2 participants