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

openOnFocus Option Ineffective #1828

Open
stevenae opened this issue Jan 23, 2025 · 9 comments
Open

openOnFocus Option Ineffective #1828

stevenae opened this issue Jan 23, 2025 · 9 comments

Comments

@stevenae
Copy link

Python ShinyExpress, developing locally. I am using ui.input_selectize. By default, an initial click into the selectize box shows the items dropdown. The selectize documentation shows the option openOnFocus, a boolean, for accomplishing this: https://selectize.dev/docs/usage.

When I add this to the options dict in my ui.input_selectize initialization, the behavior does not change.

@gadenbuie
Copy link
Collaborator

gadenbuie commented Jan 23, 2025

Can you please include an example app showing how you're using options and ui.input_selectize()? FYI, if it's helpful, you can use https://shinylive.io/py/editor to create and run the app in your browser.

*Edit: please include the code for an example app

@stevenae
Copy link
Author

stevenae commented Jan 23, 2025

My example is live at https://realdealfinder.shinyapps.io/real-deal-finder/

EDIT: updated this live example to include openOnFocus in options.

@gadenbuie
Copy link
Collaborator

Thanks, but what I really need is the source code, which I can't access from the deployed app.

@stevenae
Copy link
Author

stevenae commented Jan 23, 2025 via email

@gadenbuie
Copy link
Collaborator

Here's a small app (view on shinylive):

from shiny.express import input, render, ui

ui.input_selectize(
    id="selectize",
    label="Homes to compare:",
    choices=["A", "B", "C", "D", "E", "F"],
    multiple=True,
    options={
        "placeholder": "Click here to enter address",
        "closeAfterSelect": True,
        "maxOptions": 3,
        "openOnFocus": False,
    },
)


@render.code
def txt():
    return input.selectize()

It turns out that openOnFocus does work, just that it means keyboard focus. Clicking on the input always opens the dropdown, but if you have openOnFocus: false and navigate to the input via the keyboard, the dropdown doesn't open.

@stevenae
Copy link
Author

stevenae commented Jan 24, 2025 via email

@gadenbuie
Copy link
Collaborator

Oh, actually, I think we might be doing something that's causing the click to expand the dropdown. I made a small vanilla js/html example and the click doesn't expand the dropdown when openOnFocus: false: https://codepen.io/gadenbuie/pen/RNbqomL

We'll look into this, thanks for opening the issue!

@gadenbuie
Copy link
Collaborator

...oops, I have to take that back. openOnFocus: false suppressed opening the dropdown for click events in selectize 0.14.0 and that behavior changed somewhere between then and the latest release, v0.15.2, which we use. So this is primarily an upstream bug in selectize.

@stevenae
Copy link
Author

stevenae commented Jan 24, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants