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

Infinite loop while selecting text inside table cell #1443

Open
vmorreel opened this issue Feb 21, 2024 · 0 comments
Open

Infinite loop while selecting text inside table cell #1443

vmorreel opened this issue Feb 21, 2024 · 0 comments
Labels
bug:plugin Bug in a plugin

Comments

@vmorreel
Copy link

Bug case

When selecting text inside table cells, then the selection propagates to the cell, then the browser tab completely freeze.

It happens only when :

  • having a trumbowyg initialized on page
  • having a table drawn on page
  • And when selecting cells which have colspan attribute containing NaN value (supposed same behavior with rowspanattribute).
    In my case, I'm using Mustache JS for templating views which causing the problem with my template row.

My template row is as follow :

<td class="border-left" colspan="{{^mustache_condition}}2{{/mustache_condition}}">My cell content</td>

The bug come from the while loop at line 533 of trumbowyg.table.min.js :

while (tableState[rowIndex][columnIndex] !== undefined) {
    columnIndex += 1;
}

So, in my case my colspan attribute is NaN value {{^mustache_condition}}2{{/mustache_condition}}.

Checking if !isNaN(colspanAttr) in ternary line 530 of trumbowyg.table.min.js resolves the issue.
(supposed same behavior with rowspanattribute)

Maybe add scope on selection only on table inside a trumbowyg element could be a nicer solution?

Description

Context:

  • Chrome 122.0.6261.58 / Firefox 124.0b1 (bug occurs on all browsers)

How to reproduce?

Here's a fiddle to reproduce the error : https://jsfiddle.net/wqk2xLjr/10/

@Alex-D Alex-D added the bug:plugin Bug in a plugin label Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:plugin Bug in a plugin
Projects
None yet
Development

No branches or pull requests

2 participants