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] Table rows not shown correctly #1383

Open
emaborsa opened this issue Oct 4, 2023 · 4 comments
Open

[BUG] Table rows not shown correctly #1383

emaborsa opened this issue Oct 4, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@emaborsa
Copy link

emaborsa commented Oct 4, 2023

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.7.10, on Microsoft Windows [Version 10.0.19044.3448], locale de-DE)
[X] Windows Version (Unable to confirm if installed Windows version is 10 or greater)
Checking Android licenses is taking an unexpectedly long time...[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.7.4)
[√] Android Studio (version 2022.1)
[√] VS Code, 64-bit edition (version 1.82.2)
[√] Connected device (5 available)
[√] HTTP Host Availability

! Doctor found issues in 1 category.

flutter_html version 2.2.1

Problem: Tables are rendered with padding/margin?

conv2

Expected output

conv1

HTML sample

<style>
  td p {
    background-color: orange;
  }
  td {
    border-bottom: 1px #000000 solid;
  }
  
</style>
<table cellpadding="0" cellspacing="0" style="border-collapse: collapse">
  <tbody>
    <tr>
      <td>
        <b>
          <strong>Modelle</strong>
        </b>
      </td>
      <td>
        <b>
          <strong>Rabatt</strong>
        </b>
      </td>
    </tr>
    <tr>
      <td>
        <p>
          <span>Cupra Leon, Cupra leon Sportstourer </span>
        </p>
      </td>
      <td>
        <p>
          <span>15 % </span>
        </p>
      </td>
    </tr>
    <tr>
      <td>
        <p>
          <span>Cupra Ateca</span>
        </p>
      </td>
      <td>
        <p>
          <span>18 % </span>
        </p>
      </td>
    </tr>
    <tr>
      <td>
        <p>
          <span>Cupra Formentor</span>
        </p>
      </td>
      <td>
        <p>
          <span>14 %</span>
        </p>
      </td>
    </tr>
    <tr>
      <td>
        <p>
          <span>Cupra Formentor E-Hybrid</span>
        </p>
      </td>
      <td>
        <p>
          <span>13 %</span>
        </p>
      </td>
    </tr>
    <tr>
      <td>
        <p>
          <span>Cupra born</span>
        </p>
      </td>
      <td>
        <p>
          <span>  8 % </span>
        </p>
      </td>
    </tr>
  </tbody>
</table>
@emaborsa emaborsa added the bug Something isn't working label Oct 4, 2023
@emaborsa
Copy link
Author

emaborsa commented Oct 4, 2023

For test purpuses I added a customRender as followings:

customRender: {
  "td": (context, parsedChild) {
    return Container(
      child: Text("OK"),
      decoration: BoxDecoration(
        border: Border(
          bottom: BorderSide(
            color: Colors.black,
            width: 1,
            style: BorderStyle.solid))));
  }
},

The output:
conv3

Where do the spaces come from?

@emaborsa
Copy link
Author

emaborsa commented Oct 4, 2023

If I add a customRender for tr, it is completely ignored.

@erickok
Copy link
Contributor

erickok commented Oct 4, 2023

It's coming from the p tags. Seems like a bug (regression).

@emaborsa
Copy link
Author

emaborsa commented Oct 5, 2023

I tried to find a workaround, removing the styles:

customRender: {
  "td": (context, parsedChild) {
    if (parsedChild is ContainerSpan) {
      return ContainerSpan(
        newContext: context,
        style: Style(),
        shrinkWrap: parsedChild.shrinkWrap,
        children: parsedChild.children);
    }

    return parsedChild;
  },
  "p": (context, parsedChild) {
    if (parsedChild is ContainerSpan) {
      return ContainerSpan(
        newContext: context,
        style: Style(backgroundColor: Colors.orange),
        shrinkWrap: parsedChild.shrinkWrap,
        children: parsedChild.children);
    }

    return parsedChild;
  },
  "span": (context, parsedChild) {
    if (parsedChild is ContainerSpan) {
      return ContainerSpan(
        newContext: context,
        style: Style(backgroundColor: Colors.yellow),
        shrinkWrap: parsedChild.shrinkWrap,
        children: parsedChild.children);
    }

    return parsedChild;
  }
},

Don't understand where the spaces come from:
WhatsApp Image 2023-10-05 at 09 19 01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants