Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow only initial selection for Nav #565

Open
mturoci opened this issue Feb 12, 2021 · 3 comments
Open

Allow only initial selection for Nav #565

mturoci opened this issue Feb 12, 2021 · 3 comments
Labels
feature Feature request ui Related to UI

Comments

@mturoci
Copy link
Collaborator

mturoci commented Feb 12, 2021

Is your feature request related to a problem? Please describe

A tour.py could improve its UX by preselecting nav item based on active hash.

Describe the solution you'd like

Introduce initial_value attr on ui.nav_card.

Describe alternatives you've considered

Tried to use value, but this allows app developers to manually control which nav item is currently active (clicking on other items does not work out of the box unless handled in python code via value). However, I only care about the initial selection without further overhead.

@mturoci mturoci added ui Related to UI feature Feature request labels Feb 12, 2021
@mturoci mturoci self-assigned this Feb 12, 2021
@lo5
Copy link
Member

lo5 commented Feb 12, 2021

The initial_value / value duo introduces a new kind of behavior that might need to be applied to all such components going forward.

It would be good to solve this problem without introducing the initial_value attribute.

I don't think there is a scenario where the app author will want to control the value on every click. It's more likely that the app author intends the value to be an initial value, and then have the nav behave normally for subsequent clicks.

What do you think about:

  • When a value is specified, we use that to initialize the nav, and store it in an internal initialValue variable.
  • When an item is clicked, we use that as the active item (ignore the value attribute).
  • If the app author changes the value explicitly later, we can detect that by comparing state.value with our initialValue variable, and use that to set the active item.

@mturoci
Copy link
Collaborator Author

mturoci commented Feb 15, 2021

Brilliant proposal @lo5!

I don't think there is a scenario where the app author will want to control the value on every click. It's more likely that the app author intends the value to be an initial value, and then have the nav behave normally for subsequent clicks.

I 100% agree, however, it seems like there can be some people needing that - see #283.

I went through all the components using value and it seems like we are not consistent in this behavior. Some components use it for initial value only and some for full control. I suggest applying your proposal and unify all the components to have the same behavior. However, note this might be a breaking change for some apps unfortunately.

@mturoci
Copy link
Collaborator Author

mturoci commented Aug 16, 2022

Part of #1154

@mturoci mturoci removed their assignment Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request ui Related to UI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants