Skip to content

Conversation

@Mick235711
Copy link
Contributor

@Mick235711 Mick235711 commented Nov 18, 2025

Motivation

Currently, ui.range is completely unusable if you don't provide a value, despite its calling signature suggests that the value parameter is optional. For example, given the following code:

from nicegui import ui

ui.range(min=0, max=100)
ui.range(min=0, max=100, value={"min": 0, "max": 100})
ui.run()

Only one range slider will be shown, which seems to be confusing for beginners. Worse, there are no warnings/errors printed to the console, and the HTML is just blank for the first element.

Implementation

Provide a proper default value to the value parameter, initializing to the full range. Alternatively, we can also move value to be a required parameter (remove = None) to accurately reflect its nature.

Progress

  • I chose a meaningful title that completes the sentence: "If applied, this PR will..."
  • The implementation is complete.
  • Pytests are added.
  • Documentation has been added.

@evnchn
Copy link
Collaborator

evnchn commented Nov 19, 2025

Hello @Mick235711 thanks for the PR.

It's a fair fix. And retrospect we're actually kinda sloppy in terms of the types passed into Quasar across the library, passing Nones despite the intended type is str, for example. (NiceGUI wishlist, maybe?)

image

Generally fine for str but in the case of ui.range it broke things because it expects a dict.

@codingpaula As the initial author for ui.range, do read this in case I missed anything. Thanks!

Copy link
Contributor

@falkoschindler falkoschindler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pull request, @Mick235711!
I wasn't aware that ui.range is broken if you only specify the required parameters min and max. Your PR seems to fix it perfectly.
Let's merge! 🚀

@falkoschindler falkoschindler added bug Type/scope: A problem that needs fixing review Status: PR is open and needs review labels Nov 19, 2025
@falkoschindler falkoschindler added this to the 3.4 milestone Nov 19, 2025
@falkoschindler falkoschindler added this pull request to the merge queue Nov 19, 2025
Merged via the queue into zauberzeug:main with commit b6305a1 Nov 19, 2025
6 checks passed
@Mick235711 Mick235711 deleted the better-range branch November 19, 2025 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Type/scope: A problem that needs fixing review Status: PR is open and needs review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants