magesuite / theme-creativeshop

Open Software License 3.0
38 stars 24 forks source link

Checkout broken since 15.1.7 #95

Closed fritzmg closed 2 years ago

fritzmg commented 2 years ago

The following changes broke the checkout for us: https://github.com/magesuite/theme-creativeshop/compare/v15.1.6...v15.1.7 with the following JavaScript error:

Uncaught ReferenceError: Unable to process binding "attr: function(){return {
        name:inputName,placeholder:placeholder,'aria-describedby':getDescriptionId(),'aria-required':required,'aria-invalid':error() ? true:'false',id:uid,disabled:disabled,type:type,autocomplete:autocomplete,pattern:pattern,maxlength:maxlength} }"
Message: type is not defined

If I remove type: type from here, then the error will be

…
Message: autocomplete is not defined

etc.

It looks like the src/Magento_Ui/web/templates/form/element/input.html is using variables, that will never be initialized? In total the following variables are not available:

So If I change the template to

 <!--
 /**
  * Template overridden in order to add maxlength attribute
  * Aligned with Magento 2.4.3 at (6.10.2021)
  */
 -->
 <input class="input-text" type="text" data-bind="
     value: value,
     valueUpdate: 'keyup',
     hasFocus: focused,
     attr: {
         name: inputName,
         placeholder: placeholder,
         'aria-describedby': getDescriptionId(),
         'aria-required': required,
         'aria-invalid': error() ? true : 'false',
         id: uid,
         disabled: disabled,
-        type: type,
-        autocomplete: autocomplete,
-        pattern: pattern,
         maxlength: maxlength
     }" />

then everything works again.

Magento version: 2.4.3 CE

marcoveeneman commented 2 years ago

Thanks @fritzmg for finding this issue. I have the same problem with a freshly installed M2.4.3-p1. I pinned theme-creativeshop to 15.1.6 and the checkout seems to work now, which is ok as a temporary solution, but i'd like to actually have a real fix for the issue.

Are we missing something which causes this change to break the checkout for us? Just curious, how can it work for you guys?

drabikowy commented 2 years ago

Hello @fritzmg @marcoveeneman

The issue appeared because we used patches for Magento UI module to provide input field attributes in XML and the template (https://github.com/magesuite/magento-patches/blob/master/essential/autocomplete-checkout-inputs-setup.patch). Then we decided to add maxlength, which ended up with an overwritten template, but not an original - patched one. We will have to decide if we should stick to patches, also for maxlength, or rather overwrite everything in the theme and provide also XML changes that add these attribute values. Rather second option, maybe in future releases we will do it like this.

For now, we merged this contribution, thanks a lot for pointing this out.

New MageSuite package with v16 of theme-creativeshop will be released this or next week.

Best regards!