Skip to content

Commit fc09872

Browse files
feat(gh-16133): add repro for multiselect cursor jump on keyboard select (#76)
Add a reproduction app and notes for streamlit/streamlit#16133, where the multiselect text caret jumps to the beginning of the input after clearing and re-selecting an option with the keyboard. The app walks through the keyboard-only steps that trigger the caret regression and records the environment, expected/actual behavior, and P3 triage in NOTES.md so the issue explorer surfaces it like the other gh-* repros. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent e6514df commit fc09872

2 files changed

Lines changed: 99 additions & 0 deletions

File tree

issues/gh-16133/NOTES.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# gh-16133: multiselect cursor jumps to start after keyboard re-selection
2+
3+
## Summary
4+
5+
When an option is chosen in `st.multiselect` using the keyboard, the text
6+
caret is placed correctly (at the end) on the first selection. After the user
7+
clears the selection with **Escape** and selects again, the caret jumps to the
8+
**beginning** of the input, so subsequently typed characters are inserted
9+
before the existing content instead of after it.
10+
11+
## Reproduction
12+
13+
- **Version:** `streamlit>=1.60.0` (reported on 1.60.0).
14+
- **Steps:**
15+
1. Click the multiselect to focus it.
16+
2. Type `Red`, press Enter.
17+
3. Press Escape twice (close dropdown + clear).
18+
4. Type `Red` again, press Enter.
19+
5. Keep typing — the caret is at the start of the input, not the end.
20+
- **Browsers reported:** Edge, Opera, Firefox.
21+
22+
## Classification
23+
24+
- **Type:** Bug (frontend, keyboard/caret handling in the multiselect input).
25+
- **Status:** Confirmed bug per the issue; marked as a regression.
26+
- **Areas:** frontend — `Multiselect` widget input / React Aria combobox caret
27+
management.
28+
- **Priority:** P3 (medium) per the issue triage — a keyboard-usability
29+
annoyance affecting a specific interaction sequence, with no data loss and a
30+
simple mouse-based workaround (click at the end of the input before typing).

issues/gh-16133/app.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
"""
2+
Reproduction for GitHub Issue #16133
3+
Title: After entering an option with the keyboard in a multiselect, the cursor
4+
is positioned at the beginning of the multiselect
5+
URL: https://github.com/streamlit/streamlit/issues/16133
6+
7+
Expected: After picking an option with the keyboard, the text cursor stays at
8+
the end of the input, so the next typed characters appear where you
9+
expect them.
10+
Actual: After clearing the selection (Escape) and re-selecting an option, the
11+
cursor jumps to the beginning of the multiselect input, so newly typed
12+
text is inserted before the placeholder/existing content.
13+
Reported version: 1.60.0
14+
"""
15+
16+
import streamlit as st
17+
18+
st.title("Issue #16133: multiselect cursor jumps to start after keyboard select")
19+
st.info("🔗 [View original issue](https://github.com/streamlit/streamlit/issues/16133)")
20+
21+
# --- Issue Overview ---
22+
st.header("Issue Overview")
23+
st.write(
24+
"**Expected:** After selecting an option with the keyboard, the text cursor "
25+
"remains at the end of the input so the next characters you type land where "
26+
"you expect."
27+
)
28+
st.error(
29+
"**Actual (Bug):** After the first keyboard selection the cursor sits after "
30+
"the chosen item, but once you clear the selection and re-select, the cursor "
31+
"jumps to the *beginning* of the input, making further typing hard to follow."
32+
)
33+
34+
st.divider()
35+
36+
# --- Bug Demonstration ---
37+
st.header("Bug demonstration")
38+
st.write(
39+
"""
40+
**Steps (keyboard only, no mouse after the first click):**
41+
1. Click the multiselect below to focus it.
42+
2. Type `Red` and press **Enter** — "Red" is selected.
43+
3. Press **Escape** twice to close the dropdown and clear the selection.
44+
4. Type `Red` again and press **Enter**.
45+
5. Start typing another query — observe the caret is at the **start** of the
46+
input instead of after your text.
47+
48+
Reported in Edge, Opera, and Firefox. This is a regression — earlier versions
49+
kept the caret at the end.
50+
"""
51+
)
52+
53+
options = st.multiselect(
54+
"What are your favorite colors?",
55+
["Green", "Yellow", "Red", "Blue"],
56+
default=[],
57+
)
58+
st.write("You selected:", options)
59+
60+
st.divider()
61+
62+
# --- Environment ---
63+
st.header("Environment")
64+
st.code(f"Streamlit version: {st.__version__}")
65+
st.code(
66+
"Reported on: Streamlit 1.60.0\n"
67+
"Browsers: Edge, Opera, Firefox\n"
68+
"Regression: yes (worked in previous versions)"
69+
)

0 commit comments

Comments
 (0)