-
-
Notifications
You must be signed in to change notification settings - Fork 144
Add more Input tests, remove duplicate value callbacks. #384
Conversation
@T4rk1n The input has been changed to fire |
@valentijnnieman That is fine for the call count tests. But there's still the bug in #362, it's hard to reproduce by hand because you have to type and change focus very fast, but it can happen. The only way I had that test not fail is by removing the |
This is one of the errors I am experiencing in plotly/dash-renderer#100. Is the other error also caused by this. It looks like the |
Both of those errors comes from that. The input get cleared ok, but it get the initial value back in componentWillReceiveProps caused by |
okay, thanks! |
@T4rk1n Are you still working on this? Would be good to get this fixed! |
The only fix for that bug is removing the componentWillReceiveProps, it would remove the debounce logic for the number type. Maybe we can have another logic instead for that case. Like caching the value when the type is number and only setting it while setting n_blur/n_submit and only use the props for render. |
3699717
to
967dd66
Compare
After investigating a bit more the input clear bug, it boils down to the way selenium clear the input. It doesn't send the onChange event for the cleared value so somehow the initial value get backs in. This is not something that would happen if the user cleared the input manually with backspaces or selecting the whole text and deleting. Thus, it is safe to patch the failing tests to fix that selenium bug. The callback counts were wrong because we added the debounce logic and the value was set all the time in onBlur and onSubmit. I added a check that only set the value if debounce is true, removing the duplicate value callbacks. |
@valentijnnieman Please review |
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.
👍 Very happy these tests got fixed, thanks @T4rk1n! Got 2 small comments.
src/components/Input.react.js
Outdated
@@ -65,22 +65,27 @@ export default class Input extends Component { | |||
if (setProps) { | |||
const castValue = | |||
type === 'number' ? Number(value) : value; |
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.
For consistency, the way the payload
is set up should probably be the same in the onBlur
method as well as in the onKeyPress
method. I might prefer the way it's done on line 86 - the castvalue
const also shouldn't have to be defined if it's not being used here.
test/test_integration.py
Outdated
@@ -1446,3 +1452,127 @@ def _insert_cookie(rep): | |||
self.wait_for_text_to_equal('#content', 'Logged out') | |||
|
|||
self.assertFalse(self.driver.get_cookie('logout-cookie')) | |||
|
|||
def test_lose_focus_input(self): |
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.
Is this test really different from the test_simple_callback
one? There, on line 1569, the input also loses focus. Perhaps this test could be removed?
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.
Looks good 👍
This PR adds a failing
Input
test and fixwait_for_text_to_equal
that only checked if the text was present and not equal.Tests are failing in
dash
anddash-renderer
if we update the dash-core-components version to the latest.