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

Revamp event handling in text boxes and add continuous_update option #1545

Merged
merged 11 commits into from Jul 31, 2017

Conversation

Projects
None yet
2 participants
@jasongrout
Member

jasongrout commented Jul 27, 2017

  • Check the width of float/int/bounded text boxes now - they seem to be shorter.
  • deprecate the on_submit handler for text boxes, and handle the events similar to how things are done in this PR (with input and change events).

Also, specialize those inputs to type number, and add a step option.

I default continuous_update to False for the textboxes because I figured if people were typing, that's typically what is wanted.

FIxes #584 and #1401.

jasongrout added some commits Jul 27, 2017

Add a step for the bounded int/float textboxes to make them compatibl…
…e with sliders.

This also is needed to make the spinners in the new number inputs work appropriately, especially with floating point numbers.
@jasongrout

This comment has been minimized.

Member

jasongrout commented Jul 27, 2017

CC @mpacer

@jasongrout

This comment has been minimized.

Member

jasongrout commented Jul 27, 2017

@mpacer (or anyone), if you have a better name than "continuous_update", I'm all ears...

jasongrout added some commits Jul 27, 2017

Add continuous_update option to Text and Textarea.
Deprecate the Text on_submit handler.
Fix an issue with typing in numbers with continuous update.
Basically, if you typed ‘3.’, it would parse the number as 3 and reset the value, so you could never type the decimal.

Also, fixed some issues with min, max, and step being set, especially if they were undefined.
Give the FloatText and IntText a step attribute.
For floats, a step of None means any step is allowed.
@jasongrout

This comment has been minimized.

Member

jasongrout commented Jul 27, 2017

@mpacer, I think this is ready to go. Would you like to give it a spin before merging, or would it be easier to merge and spin off another beta for you to take a look at?

@mpacer

This comment has been minimized.

Contributor

mpacer commented Jul 27, 2017

I can give it a spin before the end of the day :) thanks for getting to this so quickly!

@jasongrout jasongrout changed the title from Add continuous_update option to int/float text boxes to Revamp event handling in text boxes and add continuous_update option Jul 27, 2017

@mpacer

This comment has been minimized.

Contributor

mpacer commented Jul 27, 2017

I think it would help to include in the docstrings what the default behaviour is (i.e., when continuous_update is set to False). E.g., does it send when either you hit enter/return or change focus as asked for in #584?

@mpacer

This comment has been minimized.

Contributor

mpacer commented Jul 27, 2017

Also it'd be good to have an example in the docs of both kinds of behaviour. Probably in the Widgets Event section. This shouldn't need backend connections as far as I can tell so it should explain the behaviour nicely in the docs with two appropriate examples.

Also, you probably want to remove the Special Events on_submit section from the docs if it's deprecated.

@mpacer

This comment has been minimized.

Contributor

mpacer commented Jul 27, 2017

So this almost works, but there is bug in the continuous_update version of this if you select text and then delete it (rather than just deleting single characters):

widget_ct_up_del

@jasongrout

This comment has been minimized.

Member

jasongrout commented Jul 27, 2017

So this almost works,

I'm entirely relying on the browser events, hoping that they Do The Right Thing [1]. Does it have the behavior in other browsers too?

[1] Perhaps too optimistic? Our hopes have been dashed many times before...

@jasongrout

This comment has been minimized.

Member

jasongrout commented Jul 27, 2017

Oh, the issue there is that when you delete, it recognizes it's not a number, so it's patiently waiting for you to type something that is a number.

@jasongrout

This comment has been minimized.

Member

jasongrout commented Jul 27, 2017

(that's also why it resets when you click out - if the value is not valid, it resets to the previous value)

@jasongrout

This comment has been minimized.

Member

jasongrout commented Jul 27, 2017

Also, you probably want to remove the Special Events on_submit section from the docs if it's deprecated.

Right - doc changes coming up...

@jasongrout

This comment has been minimized.

Member

jasongrout commented Jul 27, 2017

Oh, the issue there is that when you delete, it recognizes it's not a number, so it's patiently waiting for you to type something that is a number.

What if we put in a placeholder like "Type a number" or something? That would show if you deleted everything in the box. Would that be enough of a hint?

@jasongrout jasongrout force-pushed the jasongrout:submit branch from de5a548 to 53515bb Jul 27, 2017

@jasongrout

This comment has been minimized.

Member

jasongrout commented Jul 27, 2017

@mpacer, I updated the docs. Thoughts?

@jasongrout jasongrout merged commit d9e3f23 into jupyter-widgets:master Jul 31, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@jasongrout

This comment has been minimized.

Member

jasongrout commented Jul 31, 2017

Merging - @mpacer, feel free to open another issue if you see something we missed.

@jasongrout jasongrout added this to the 7.0 milestone Aug 1, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment