From 97a67f62825c51dacbd8308ac446cf044956d573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 21 Jul 2021 23:59:00 +0200 Subject: [PATCH] Remove type attribute on invisible URL widget The widget may be filled with invalid content when it is invisible. issue10473 review336611003 --- src/view/form.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/view/form.js b/src/view/form.js index 9f3c1adfc8..0048b09ea3 100644 --- a/src/view/form.js +++ b/src/view/form.js @@ -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('', { '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); }