flutter_html icon indicating copy to clipboard operation
flutter_html copied to clipboard

[BUG] Double drawn border if style and customRender combined

Open matecode opened this issue 2 years ago • 3 comments

Describe the bug: If i combine style and customRender i get an unexpected result of a double drawn border. I don't want to rule out the possibility that I made a mistake, but i think more its a bug ;)

HTML to reproduce the issue:

    <div class="outer">
       <div class="inner">
       Test
       </div>
    </div>

Html widget configuration:

Html(
      shrinkWrap: true,
      data: *the above html content*,
      style: {
        ".outer .inner": Style(
          border: Border.all(color: Colors.blue, width: 1),
          padding: const EdgeInsets.all(20),
          backgroundColor: Colors.red,
        ),
      },      
      customRender: {
        "div": (context, child) {
          return child;
        }
      },
    );

Expected behavior: Only one border is drawn around the inner div

Screenshots: image

Device details and Flutter/Dart/flutter_html versions: flutter_html: ^2.2.1 • Flutter version 2.5.3 • Dart version 2.14.4

A picture of a cute animal (not mandatory but encouraged) image

matecode avatar Feb 16 '22 14:02 matecode

This would likely be a bug in our html parser package (dart html) if this is the case, because it would match your selector to the outer class as well. We don't have any algorithm internally for matching a selector to the element.

tneotia avatar Feb 16 '22 23:02 tneotia

As I'm not an CSS extpert, the style ".outer .inner" should apply the border only to the inner div, right? As you mentioned i guess there is a bug. Can I further help to fix it? I had a look into custom_render.dart, but I could figure out quick what the problem could be. Let me know if I can help on another end (maybe sending cute animals)

matecode avatar Feb 17 '22 07:02 matecode

Seems to be an issue with the descendant combinator. Perhaps try .outer > .inner?

Sub6Resources avatar Jun 10 '22 17:06 Sub6Resources