Closed juliohm closed 2 years ago
Hey Júlio! I think Slider
just falls back to the number that's in the "middle" if the original default value we specify doesn't live in our range once it's materialized:
using PlutoUI
@bind x PlutoUI.Slider([1, 10, 42, 1_000], default=7)
x
which seems reasonable to me. So changing the default value in your example to something like 2360.0
should do the trick then I think
Hi Ian! I think this is a bit counter intuitive. A more natural behavior would be to show an error saying that the default is not in the range, or return the closest value in the range as the default. Right now this value is being silently passed forward, which causes more serious issues downstream.
Alternatively, make this default an initial value ignoring the specified range. The keyword default=1.0 means init=1.0, right?
Yea, I can definitely see users potentially getting tripped up by this. I'm thinking now that trying to avoid as much mind-reading as possible might be the best way forward, so I really like your suggestion to just raise an error. I'm seeing now that this could also avoid potentially confusing outputs like these:
The keyword default=1.0 means init=1.0, right?
Sorry, I'm not sure what you mean by this
Sorry I tried to ask if the keyword default=1.0 has the meaning "initial value is 1.0". Maybe the keyword could be renamed in a future breaking release? Maybe Im asking it is just because I'm not a native speaker. Default should be fine i guess.
On Tue, Jan 4, 2022, 20:03 Ian Weaver @.***> wrote:
Yea, I can definitely see users potentially getting tripped up by this. I'm thinking now that trying to avoid as much mind-reading as possible might be the best way forward, so I really like your suggestion to just raise an error. I'm seeing now that this could also avoid potentially confusing outputs like these:
[image: Screenshot from 2022-01-04 18-01-29] https://user-images.githubusercontent.com/25312320/148135642-b1c39e27-d95a-4a93-acfa-6628b5e23ac5.png
The keyword default=1.0 means init=1.0, right?
Sorry, I'm not sure what you mean by this
— Reply to this email directly, view it on GitHub https://github.com/JuliaPluto/PlutoUI.jl/issues/175#issuecomment-1005235627, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZQW3MFVRW5RX2W6C5D663UUN4FVANCNFSM5KLEACVA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>
Ahh, gotcha, was just a misunderstanding on my end. I believe it does (or at least should if 1.0 is in the array formed from the range that's passed to it), so I agree that the name is fine too. If no default is given, then it just falls back to the first element of the array
oop, found related discussion in #58
Here is the code to reproduce: