Projet

Général

Profil

0001-JS-add-form-with-error-class-to-body-if-form-contain.patch

Thomas Jund, 04 novembre 2020 15:37

Télécharger (1,47 ko)

Voir les différences:

Subject: [PATCH] JS: add form-with-error class to body if form contain error
 (#48003)

 wcs/qommon/static/js/qommon.forms.js | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
wcs/qommon/static/js/qommon.forms.js
230 230
    if ($date_input.data('end-date')) options.endDate = $date_input.data('end-date');
231 231
    $date_input.datetimepicker(options);
232 232
  });
233
  if ($('.widget-with-error').length && $('.global-errors').length == 0) {
234
    var first_field_with_error = $($('.widget-with-error')[0]).find('input,textarea,select');
235
    if (first_field_with_error.length) {
236
      $(first_field_with_error)[0].focus();
233
  // Form with error
234
  const first_widget_with_error = document.querySelector('.widget-with-error');
235
  if (first_widget_with_error) {
236
    document.body.classList.add('form-with-error');
237
    if (!document.querySelector('.global-errors')) {
238
      const first_field_with_error = first_widget_with_error.querySelector('input,textarea,select');
239
      first_field_with_error.focus();
237 240
    }
238 241
  }
242

  
239 243
  $(window).bind('pageshow', function(event) {
240 244
    $('form').removeClass('disabled-during-submit');
241 245
  });
242
-