daohoangson / flutter_widget_from_html

Flutter package to render html as widgets that supports hyperlink, image, audio, video, iframe and many other tags.
https://pub.dev/packages/flutter_widget_from_html
MIT License
635 stars 235 forks source link

Anchor links scroll down but not up #1106

Open Maybells opened 10 months ago

Maybells commented 10 months ago

Steps to Reproduce

HTML ```html ```
`HtmlWidget` configuration ```dart HtmlWidget( html, key: htmlKey, renderMode: RenderMode.listView, onTapUrl: (url) { print(url); return false; }, ); ```
Tesing environment ``` [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at C:\Users\Maybells\AppData\Local\Android\sdk • Platform android-34, build-tools 34.0.0 • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231) • All Android licenses accepted. [X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. [√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.0) • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools • Visual Studio Build Tools 2019 version 16.11.31605.320 • Windows 10 SDK version 10.0.19041.0 [√] Android Studio (version 2022.3) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231) [√] VS Code (version 1.82.0) • VS Code at C:\Users\Maybells\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.74.0 [√] Connected device (2 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.2715] • Edge (web) • edge • web-javascript • Microsoft Edge 119.0.2151.72 [√] Network resources • All expected network resources are available. ! Doctor found issues in 1 category. ```

Expected results

Clicking on an anchor link should take you to the anchor with the corresponding id.

Actual results

Links to locations further down the page work fine, but links that go up do nothing. The onTapUrl function is still called, but the widget doesn't scroll to the new location. In addition, the problem persisted when I reordered the html elements while keeping their ids and hrefs the same (so it's not an issue with those, only scroll direction).

daohoangson commented 10 months ago

Can you provide the HTML?

Also, can you try the demo app here https://demo.fwfh.dev/#/hugehtml ? It works with both up and down direction for me.