Skip to content

[fix] Selectbox with accept_new_options on mobile shows keyboard#12219

Merged
sfc-gh-bnisco merged 4 commits intodevelopfrom
bnisco/fix-12205
Aug 15, 2025
Merged

[fix] Selectbox with accept_new_options on mobile shows keyboard#12219
sfc-gh-bnisco merged 4 commits intodevelopfrom
bnisco/fix-12205

Conversation

@sfc-gh-bnisco
Copy link
Copy Markdown
Collaborator

@sfc-gh-bnisco sfc-gh-bnisco commented Aug 14, 2025

Describe your changes

  • Fixes a mobile usability issue with the accept_new_options argument that was added a few months ago to st.selectbox.

Here it is working on the preview app from this branch in iOS:
IMG_3975

GitHub Issue Link (if applicable)

Fixes #12205

Testing Plan

  • ✅ Unit tests added
  • ✅ Manually tested on iOS

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@sfc-gh-bnisco sfc-gh-bnisco added security-assessment-completed change:bugfix PR contains bug fix implementation impact:users PR changes affect end users labels Aug 14, 2025
@snyk-io
Copy link
Copy Markdown
Contributor

snyk-io bot commented Aug 14, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 14, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-12219/streamlit-1.48.1-py3-none-any.whl
🕹️ Preview app pr-12219.streamlit.app (☁️ Deploy here if not accessible)

@sfc-gh-bnisco sfc-gh-bnisco requested a review from Copilot August 14, 2025 15:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where selectbox with accept_new_options enabled on mobile devices would prevent the keyboard from appearing, making it impossible for users to type new options. The fix ensures that when acceptNewOptions is true, the input field is not set to readonly on mobile devices, allowing users to enter custom values.

  • Modified the readonly condition to consider the acceptNewOptions prop
  • Added comprehensive test coverage for mobile behavior with both enabled and disabled acceptNewOptions

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
frontend/lib/src/components/shared/Dropdown/Selectbox.tsx Updated readonly condition to allow keyboard input when acceptNewOptions is true
frontend/lib/src/components/shared/Dropdown/Selectbox.test.tsx Added mobile-specific tests to verify keyboard behavior with acceptNewOptions

@sfc-gh-bnisco sfc-gh-bnisco marked this pull request as ready for review August 14, 2025 16:14
Copy link
Copy Markdown
Collaborator

@mayagbarnes mayagbarnes left a comment

Choose a reason for hiding this comment

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

👍🏼 LGTM

@sfc-gh-bnisco sfc-gh-bnisco enabled auto-merge (squash) August 14, 2025 22:16
@sfc-gh-bnisco sfc-gh-bnisco merged commit 00cbbb9 into develop Aug 15, 2025
37 of 38 checks passed
@sfc-gh-bnisco sfc-gh-bnisco deleted the bnisco/fix-12205 branch August 15, 2025 00:25
sfc-gh-bnisco added a commit that referenced this pull request Aug 28, 2025
…vior (#12330)

## Describe your changes

- We previously fixed a bug in `st.selectbox`
(#12219), but not in
`st.multiselect`. Ultimately, this is because the code is effectively
duplicated between the 2, despite much of the behavior needing to be the
same.
- This PR moves the shared logic into a shared place, thus reducing
duplication and fixing the bug in both places as expected.

## GitHub Issue Link (if applicable)

## Testing Plan

- ✅ Updated unit tests

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:bugfix PR contains bug fix implementation impact:users PR changes affect end users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

st.selectbox(..., accept_new_options=True) does not allow adding new options on mobile (iOS & Android)

3 participants