Skip to content

Commit 7240cb7

Browse files
authored
Fix jumpy cursor in numeric filter (#640)
1 parent 8c7207d commit 7240cb7

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

e2e/data_frame/test_data_frame.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# pyright: reportUnknownMemberType=false
22

3-
43
import re
4+
import time
55
from typing import Any, Callable
66

77
import pytest
@@ -310,7 +310,14 @@ def _filter_test_impl(
310310

311311
# Apply multiple filters, make sure we get the correct results
312312
filter_subidir_max.fill("8")
313-
filter_num1_min.fill("4")
313+
# We had a bug before where typing in a decimal point would cause
314+
# the cursor to jump to the front. Make sure that doesn't happen.
315+
filter_num1_min.focus()
316+
page.keyboard.press("3")
317+
time.sleep(0.2)
318+
page.keyboard.press(".")
319+
time.sleep(0.2)
320+
page.keyboard.press("9")
314321
expect(grid.locator("tbody tr")).to_have_count(5)
315322

316323
# Ensure changing dataset resets filters

js/dataframe/filter-numeric.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ const FilterNumericImpl: React.FC<FilterNumericImplProps> = (props) => {
7878
style={{ flex: "1 1 0", width: "0" }}
7979
type="number"
8080
placeholder={createPlaceholder(editing, "Min", props.range()[0])}
81-
value={min}
81+
defaultValue={min}
82+
step="any"
8283
onChange={(e) => {
8384
const value = coerceToNum(e.target.value);
8485
minInputRef.current.classList.toggle(
@@ -96,7 +97,8 @@ const FilterNumericImpl: React.FC<FilterNumericImplProps> = (props) => {
9697
style={{ flex: "1 1 0", width: "0" }}
9798
type="number"
9899
placeholder={createPlaceholder(editing, "Max", props.range()[1])}
99-
value={max}
100+
defaultValue={max}
101+
step="any"
100102
onChange={(e) => {
101103
const value = coerceToNum(e.target.value);
102104
maxInputRef.current.classList.toggle(

shiny/www/shared/dataframe/dataframe.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shiny/www/shared/dataframe/dataframe.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)