-
Notifications
You must be signed in to change notification settings - Fork 949
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
Adding type='password' support for Text in TextView class. #1310
Conversation
Thanks! Up to now, we've made different types of html widgets different things (e.g., the checkbox, color, radio, etc.). Following that pattern, we'd have a |
@jasongrout This is to follow the way html works. In HTML, when you pass type="password", it doesn't show it's value. If there is any other way already available, can you please share some sample code with me? |
@jakhani - I agree it would be great to make this available to users, and there's no way to do it right now. What I'm suggesting is that we either (a) make a new |
(while exposing the input |
@jasongrout Sure. I have added new widget Password. I have tested it and it's working fine. Can you please review this code? |
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.
Thanks for doing a good comprehensive job here. Looking over the code, it may be much easier (and much less code) to inherit from the Text widget and just tweak the necessary parts.
ipywidgets/widgets/widget_string.py
Outdated
|
||
|
||
@register | ||
class Password(_String): |
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.
Would it be easier to just inherit from Text?
@register
class Password(Text):
_view_name = ...
_model_name = ...
Then you inherit all of the text behavior automatically.
} | ||
|
||
export | ||
class PasswordView extends LabeledDOMWidgetView { |
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.
Again, here how about just inheriting from TextView
, and doing something like:
render() {
super.render();
this.textbox.setAttribute('type', 'password');
}
and let everything else be inherited?
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.
(the only issue I could see here is if the element is appended to the DOM before the input is set to password, the default string might flash up on the screen exposed)
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.
(i.e., that's something we should check to see if it happens)
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.
In fact, why don't we change TextView
to have a new protected attribute (at the bottom of the class), the inputType
, which for TextView
is 'text'
and is used in the render()
method, but the PasswordView
subclass just sets this to 'password'
. Then the PasswordView just becomes something like:
export
class PasswordView extends TextView {
protected inputType = 'password';
}
or something like that.
@jasongrout I have incorporated all your comments and submitted changes. Can you please have a look at it? |
@@ -661,6 +661,23 @@ Attribute | Type | Default | Help | |||
`placeholder` | string | `'\u200b'` | Placeholder text to display when nothing has been typed | |||
`value` | string | `''` | String value | |||
|
|||
### Jupyter.Password |
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.
Can you delete the changes to this file? This file is documenting the widgets as of 2.1.0 and is automatically generated. We'll generate another listing when we release the next version.
I made a few small changes (reformatting, and changing the inputType to also be readonly), and left one more comment. I'll test this tomorrow, but the code looks good to me now. Feel free to squash in my changes if you want, or leave them as separate commits - either way is fine. Thanks again! |
I have removed schema file changes. One check is failing and I am not able to get logs for the same. Can you please share detail on that in case you find anything? |
If we don't broaden the type to `string`, then overriding with a different literal throws a type error.
It seems like there is some problem with the logs on Travis right now. Hopefully my fix fixes whatever the error was. |
Thank you very much! |
@jasongrout Thanks for helping and merging it quickly. |
And congratulations on your first contribution to ipywidgets! |
Indeed, thanks for this contribution! 👍 |
@jasongrout & @maartenbreddels I am facing issues while releasing new version. We need this Password widget changes released in new version. Can you please help me out by releasing new version of ipywidgets? |
I thought this was in the alpha version - can you use our alpha release? We are working hard on finishing up what is needed for the 7.0 final release. If you need this widget before 7.0 is released, you can make a new python package with just this widget and use that in the meantime, right? |
Currently there is no way to use Text widget for Password. This code will allow to pass type while using Text widget which will allow to set type='password' for Text.