Remove type attribute on invisible URL widget

The widget may be filled with invalid content when it is invisible.

issue10473
review336611003
This commit is contained in:
Cédric Krier committed 2021-07-21 23:59:00 +02:00
1 parent c2c4ba5fc4
commit 97a67f6282
1 file changed
+12 -6
+12 -6
View File
@@ -4251,9 +4251,10 @@ function eval_pyson(value){
Sao.View.Form.URL = Sao.class_(Sao.View.Form.Char, {
class_: 'form-url',
_type: 'url',
init: function(view, attributes) {
Sao.View.Form.URL._super.init.call(this, view, attributes);
this.input.attr('type', 'url');
this.input.attr('type', this._type);
this.button = this.labelled = jQuery('<a/>', {
'class': 'btn btn-default',
'target': '_blank',
@@ -4304,15 +4305,20 @@ function eval_pyson(value){
this.button.removeClass('btn-link');
this.button.addClass('btn-default');
}
}
},
set_invisible: function(invisible) {
Sao.View.Form.URL._super.set_invisible.call(this, invisible);
if (invisible) {
this.input.attr('type', '');
} else {
this.input.attr('type', this._type);
}
},
});
Sao.View.Form.Email = Sao.class_(Sao.View.Form.URL, {
class_: 'form-email',
init: function(view, attributes) {
Sao.View.Form.Email._super.init.call(this, view, attributes);
this.input.attr('type', 'email');
},
_type: 'email',
set_url: function(value) {
Sao.View.Form.Email._super.set_url.call(this, 'mailto:' + value);
}