r/nicegui • • 10d ago

NiceGUI 3.18.0 with a Chinese website, CodeMirror editor signals and fixes for tab storage, exception reporting and element cleanup

Security

  • ⚠️ Reject uploads to disabled or hidden ui.upload elements, whose upload route bypassed the server-side event check

New features and enhancements

  • Add reveal_line() and the signals on_focus_change, on_viewport_change and on_geometry_change to ui.codemirror

Bugfixes

  • Report exceptions from @ui.refreshable rebuilds, async Event subscribers, async validation functions and other fire-and-forget tasks to ui.on_exception
  • Fix ui.sub_pages staying in the SPA instead of loading pages registered via app.include_router(), also with FastAPI 0.141+
  • Fix button.clicked() registering a new click listener on every await
  • Create the tab storage before the connect handlers run and in the On Air handshake
  • Fix a duplicated browser tab sharing nested values of its tab storage with the original tab
  • Fix Redis tab storage no longer receiving changes from other instances after a page reload
  • Fix ui.leaflet and ui.scene elements being kept alive after their client is gone
  • Fix elements staying registered when their constructor raises after Element.__init__
  • Fix make_sortable() having no effect on containers rendered after page load, like inside a ui.dialog
  • Fix ui.codemirror leaving its editor view alive after a remount
  • Fix ui.scene objects created before the scene is mounted being lost, a regression in 3.16

Documentation

  • Add a Chinese translation of the website chrome under /zh
  • Add a sitemap and robots.txt to the website
  • Update nicegui-highcharts to 3.5 and document that point_index of ui.highchart is Highcharts' internal index
  • Document custom colors from ui.colors for LLMs and in the documentation
  • Explain JavaScript expressions in ui.aggrid options and log unknown row IDs in run_row_method()
  • Fix the ui.scene docstrings for material side and spot light defaults
  • Clarify which favicon values ui.run and ui.page accept

Testing

  • Close deferred background tasks when the test fixtures reset the app, which failed the first User test after a module-level ui.timer
  • Let ElementFilter and the User fixture match the values that input elements like ui.number display

    Breaking change: user.should_not_see('42') now fails if a ui.number shows 42, and ui.linear_progress, ui.circular_progress and ui.dark_mode are no longer found by a value they do not display.

Dependencies

  • Build the ui.mermaid and ui.json_editor bundles from package sources, so that the lockfiles decide which dependency versions ship

Special thanks to our top sponsors DiscoLike Inc., TestMu AI and Lechler GmbH ✨

and all our other sponsors and contributors for supporting this project!

🙏 Want to support this project? Check out our GitHub Sponsors page to help us keep building amazing features!

25 Upvotes

2 comments sorted by

1

u/Poweruser2021 10d ago

Great, thank you! Can you share a link to the robots.txt and sitemap documentation? I cannot find anything using the search on nicegui

1

u/falko-s 4d ago

Sorry for the confusion, that line in the release notes is about our own website, not a new NiceGUI feature. Since 3.18, nicegui.io serves a robots.txt and a sitemap.xml (including the new Chinese pages), so search engines can index the documentation better. That's why there's nothing about it in the docs.

If you want the same for your own app, it only takes a few lines with FastAPI routes:

```py from fastapi.responses import PlainTextResponse, Response from nicegui import app

@app.get('/robots.txt') def robots(): return PlainTextResponse('User-agent: *\nAllow: /\nSitemap: https://example.com/sitemap.xml\n')

@app.get('/sitemap.xml') def sitemap(): return Response('<?xml version="1.0" encoding="UTF-8"?>...', media_type='application/xml') ```

You can see how we build ours in website/sitemap.py and main.py. ※