dotmailer / dotmailer-magento2-extension

The official Dotdigital for Magento2 extension
https://dotdigital.com/integrations/magento
MIT License
48 stars 64 forks source link

Add fallback selector for WBT in case #search is not present #620

Closed TomJ1588 closed 9 months ago

TomJ1588 commented 9 months ago

Additional fix on to PR 47992 - https://github.com/dotmailer/dotmailer-magento2-extension/commit/056369ac9d3971474bb7541c23ea0c77cc626d4b

What's being changed

Original PR solves the problem of JS errors but not covering a wider net to try and locatet the search value - which can be caused by search modules. Add Fallback to try and Get search input by name if no Id = search.

If can't find any, set var search to null, so previous added checks still work.

Why it's being changed

It is possible that different HTML structures can mean there is no <input id="search"> which we look for when tracking the last search term.

So add a fallback to try and locate the search input for <input name="q">

Seen modules/themes change the ID of the input, but not seen one that changes the name attribute.

Covers a wider net to allow WBT to work with more magento modules/themes.

How to review / test this change

sta1r commented 9 months ago

Thanks @TomJ1588. We're just testing this. In the meantime, if you could replace your tabs with spaces to give a clean diff that would be great.

sta1r commented 9 months ago

No worries, added a commit to fix some linting issues.

sta1r commented 9 months ago

@TomJ1588 Lovely, thanks for your input! This will be in the next master release (next week).