Skip to content
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

Add `n_blur/n_submit` to Input. #326

Merged
merged 3 commits into from Oct 22, 2018

Conversation

Projects
None yet
3 participants
@T4rk1n
Copy link
Contributor

commented Oct 12, 2018

Add four props to dcc.Input:

  • n_submit, The number of times enter was pressed when the component had focus.
  • n_submit_timestamp The last timestamp enter was pressed.
  • n_blur, The number of times the component lost focus.
  • n_blur_timestamp, The last time the component lost focus.

resolves #230

@T4rk1n T4rk1n requested a review from valentijnnieman Oct 12, 2018

@valentijnnieman
Copy link
Contributor

left a comment

Nice 💃 have just one suggestion, up to you if you want to include that in this PR.

@@ -41,6 +41,20 @@ export default class Input extends Component {
if (fireEvent) {
fireEvent({event: 'blur'});
}
if (setProps) {

This comment has been minimized.

Copy link
@valentijnnieman

valentijnnieman Oct 22, 2018

Contributor

A small improvement here could be that if setProps is set, the component doesn't need to keep state itself, i.e. if setProps is set you don't need to fire setState. If you were to implement that, you'd also need to add that logic to componentWillReceiveProps. We had a small discussion about that in #331 - it won't cause any bugs like that here but it's still a small gain to not keep unnecessary state in this component. Up to you if you want to add that now, we could always add it later if you want to just merge this first.

This comment has been minimized.

Copy link
@T4rk1n

T4rk1n Oct 22, 2018

Author Contributor

But it's not using the state.

This comment has been minimized.

Copy link
@valentijnnieman

valentijnnieman Oct 22, 2018

Contributor

Ah I was looking at line 29. That's something for another time then, feel free to merge!

This comment has been minimized.

Copy link
@T4rk1n

T4rk1n Oct 22, 2018

Author Contributor

Is there a note about that in our react dev guide ? In the SuggestionsInput, I was using componentWillReceiveProps to setState on the value, but also setState before calling setProps on the value and the value in the props and state was always different so it lead to a bug where no suggestions beyond the first was registered so it a very valid concern to think about when developing dash component.

This comment has been minimized.

Copy link
@valentijnnieman

valentijnnieman Oct 22, 2018

Contributor

Exactly, like I mentioned above I found a bug with that recently too in #331. In the Input component I don't think it'll lead to any bugs though. But it's not in the React for Python devs guide, no. Would be good to add that!

@T4rk1n T4rk1n force-pushed the input-enter-blur branch from 9f023b9 to b6dba86 Oct 22, 2018

@T4rk1n T4rk1n merged commit ee56b11 into master Oct 22, 2018

4 checks passed

ci/circleci: python-2.7 Your tests passed on CircleCI!
Details
ci/circleci: python-3.6 Your tests passed on CircleCI!
Details
ci/circleci: python-3.7 Your tests passed on CircleCI!
Details
percy/dash-core-components Visual review automatically approved, no visual changes found.
Details

@T4rk1n T4rk1n deleted the input-enter-blur branch Oct 22, 2018

@@ -37,7 +37,7 @@ def __init__(self, id=Component.REQUIRED, storage_type=Component.UNDEFINED, data
_locals.update(kwargs) # For wildcard attrs
args = {k: _locals[k] for k in _explicit_args if k != 'children'}

for k in ['id']:
for k in [u'id']:

This comment has been minimized.

Copy link
@Akronix

Akronix Oct 31, 2018

Contributor

why did you do this?

This comment has been minimized.

Copy link
@T4rk1n

T4rk1n Oct 31, 2018

Author Contributor

You commenting on auto generated code, I didn't do that.

This comment has been minimized.

Copy link
@Akronix

Akronix Oct 31, 2018

Contributor

Ah ok. Sorry if it was rude.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.