Skip to content

[BUG] Wrapping <table> in Scrollbar also wraps the elements after table #1472

@rivetingpeppermint

Description

@rivetingpeppermint

Describe the bug:
Tried to wrap table in Scrollbar, but the scrollbar wrapped all the tags after the table as well. The wrapped table should also be rendered in a new line, not the same line as the previous element. Used to work perfectly on flutter_html: ^2.2.1 (the latest version I used before updating).

HTML to reproduce the issue:

<b>
  <div>Firstline of text:</div>
  <div class="text-en">Second line of text:</div>
</b>
<p>
<table>
  <tbody>
    <tr>
      <td>No.</td>
      <td>: 1234567890</td>
    </tr>
    <tr>
      <td>Name <span class="text-en">(mandatory)</span></td>
      <td>: John Doe</td>
    <tr>
      <td>Age <span class="text-en">(mandatory)</span></td>
      <td>: 29</td>
    </tr>
    <tr>
      <td>Note <span class="text-en">(optional)</span></td>
      <td>: sample line of text</td>
    </tr>
  </tbody>
</table>
</p>
<br>
<p>
<div>Another line of text</div>
<div class="text-en">Another line of text</div> <br>Another line of text.<br>
<div class="text-en">
  Another line of text.
</div>
</p>

Html widget configuration:

Html(
    shrinkWrap: true,
    data: htmlData,
    extensions: [
      TableHtmlExtension(),
      TagWrapExtension(
          tagsToWrap: {'table'},
          builder: (child) {
            return Scrollbar(
                controller: _scrollController,
                thumbVisibility: true,
                child: SingleChildScrollView(
                  controller: _scrollController,
                  scrollDirection: Axis.horizontal,
                  child: child,
                ));
          }),
      TagExtension(
          tagsToExtend: {"img"},
          builder: (econtext) {
            return AbsorbPointer(
                absorbing: false,
                child: GestureDetector(
                    behavior: HitTestBehavior.opaque,
                    onTap: () {
                      showZoomableImage(
                          provider: NetworkImage(
                              econtext.attributes["src"]!),
                          context: econtext.buildContext);
                    },
                    child: FittedBox(
                      child: Image(
                        image: NetworkImage(
                            econtext.attributes["src"]!),
                      ),
                    )));
          }),
      TagWrapExtension(
          tagsToWrap: {'body'},
          builder: (child) {
            return DefaultTextStyle(
              style:
                  GoogleFonts.robotoFlex(letterSpacing: 0),
              child: child,
            );
          }),
      OnImageTapExtension(onImageTap: (img, _, __) {
        showZoomableImage(
            provider: NetworkImage(img!), context: context);
      })
    ],
    style: {
      "tr": Style(
        padding: HtmlPaddings.symmetric(horizontal: 5),
        margin: Margins.symmetric(horizontal: 5),
      ),
      "td": Style(
        padding: HtmlPaddings.symmetric(horizontal: 5),
        margin: Margins.symmetric(horizontal: 5),
      ),
    },
  )

Expected behavior:
Scrollbar will appear right below the table, not below the text outside the table. Table will render in a new line, not on the same line with the previous element.

Screenshots:

Image

Device details and Flutter/Dart/flutter_html versions:
Flutter 3.29.2, flutter_html: ^3.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions