-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Feature: dcc.Input accepts a number for its debounce argument #2593
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
342126a
Add ability to debounce an input field by amount of time
KoolADE85 c2f4ef9
Do not accept incoming props for input value during debounce periods
KoolADE85 fe7a8e6
Make sure to reset debounce state after timeout
KoolADE85 259b63a
Update selenium import for older python compatibility
KoolADE85 0198e20
Define input state in constructor
KoolADE85 e5cfa57
Address code review feedback
KoolADE85 1691007
fix build error
KoolADE85 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
components/dash-core-components/tests/integration/input/test_debounce.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from selenium.common import TimeoutException | ||
from selenium.webdriver.support.wait import WebDriverWait | ||
from selenium.webdriver.common.by import By | ||
import pytest | ||
|
||
|
||
def test_debounce_text_by_time(dash_dcc, debounce_text_app): | ||
dash_dcc.start_server(debounce_text_app) | ||
|
||
# expect that a long debounce does not call back in a short amount of time | ||
elem = dash_dcc.find_element("#input-slow") | ||
elem.send_keys("unit test slow") | ||
with pytest.raises(TimeoutException): | ||
WebDriverWait(dash_dcc.driver, timeout=1).until( | ||
lambda d: d.find_element(By.XPATH, "//*[text()='unit test slow']") | ||
) | ||
|
||
# but do expect that it is eventually called | ||
assert dash_dcc.wait_for_text_to_equal( | ||
alexcjohnson marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"#div-slow", "unit test slow" | ||
), "long debounce is eventually called back" | ||
|
||
# expect that a short debounce calls back within a short amount of time | ||
elem = dash_dcc.find_element("#input-fast") | ||
elem.send_keys("unit test fast") | ||
WebDriverWait(dash_dcc.driver, timeout=1).until( | ||
lambda d: d.find_element(By.XPATH, "//*[text()='unit test fast']") | ||
) | ||
|
||
assert dash_dcc.get_logs() == [] | ||
|
||
|
||
def test_debounce_number_by_time(dash_dcc, debounce_number_app): | ||
dash_dcc.start_server(debounce_number_app) | ||
|
||
# expect that a long debounce does not call back in a short amount of time | ||
elem = dash_dcc.find_element("#input-slow") | ||
elem.send_keys("12345") | ||
with pytest.raises(TimeoutException): | ||
WebDriverWait(dash_dcc.driver, timeout=1).until( | ||
lambda d: d.find_element(By.XPATH, "//*[text()='12345']") | ||
) | ||
|
||
# but do expect that it is eventually called | ||
assert dash_dcc.wait_for_text_to_equal( | ||
"#div-slow", "12345" | ||
), "long debounce is eventually called back" | ||
|
||
# expect that a short debounce calls back within a short amount of time | ||
elem = dash_dcc.find_element("#input-fast") | ||
elem.send_keys("67890") | ||
WebDriverWait(dash_dcc.driver, timeout=1).until( | ||
lambda d: d.find_element(By.XPATH, "//*[text()='67890']") | ||
) | ||
|
||
assert dash_dcc.get_logs() == [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
State should be defined in constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. Changed in 0198e20