<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Search widget in onfocusout in 4.7 causes error when used with jQuery in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-in-onfocusout-in-4-7-causes-error/m-p/186217#M17301</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With the 4.7 release, we are seeing errors coming from the onfocusout handler of the Search widget.&amp;nbsp; It was tracked down to be caused by an interaction with jQuery.&amp;nbsp; If a jQuery 'focusout' event listener is anywhere along the parent path of the search widget input, the widget's handler will error trying to walk up the parentNode path.&amp;nbsp; This is because the simulated bubble event fired by jQuery (apparently to work around some browser version focus event issues) fires with the target element at the top of the path (not the input).&amp;nbsp; The error is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;dojo.js:2072 Uncaught TypeError: Cannot read property 'parentNode' of null
at HTMLInputElement.d [as onfocusout] (dojo.js:2072)
at Object.trigger (jquery-3.3.1.js:8255)
at Object.simulate (jquery-3.3.1.js:8318)
at HTMLDocument.handler (jquery-3.3.1.js:8352)

&lt;/PRE&gt;&lt;P&gt;This can be reproduced by added jQuery and a focusout listener to any element outside the search input.&amp;nbsp; For example to any sample with a Search widget add:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;script src="https://code.jquery.com/jquery-3.3.1.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;SPAN&gt;&amp;lt;script&amp;gt;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;$(document).ready(() =&amp;gt; $('body').on('focusout', () =&amp;gt; {}));
&amp;lt;/script&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then click in the Search input control, and then click anywhere outside the Search input and check the console.&amp;nbsp; If you change the arcgisjs API version from 4.7 to 4.6 the error does not occur.&amp;nbsp;&amp;nbsp;The following jsfiddle example demonstrates this.&amp;nbsp; &lt;A href="http://jsfiddle.net/xrwfhc1n" rel="nofollow noopener noreferrer" target="_blank"&gt;http://jsfiddle.net/xrwfhc1n&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 16:09:38 GMT</pubDate>
    <dc:creator>KrisKaplan1</dc:creator>
    <dc:date>2021-12-12T16:09:38Z</dc:date>
    <item>
      <title>Search widget in onfocusout in 4.7 causes error when used with jQuery</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-in-onfocusout-in-4-7-causes-error/m-p/186217#M17301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With the 4.7 release, we are seeing errors coming from the onfocusout handler of the Search widget.&amp;nbsp; It was tracked down to be caused by an interaction with jQuery.&amp;nbsp; If a jQuery 'focusout' event listener is anywhere along the parent path of the search widget input, the widget's handler will error trying to walk up the parentNode path.&amp;nbsp; This is because the simulated bubble event fired by jQuery (apparently to work around some browser version focus event issues) fires with the target element at the top of the path (not the input).&amp;nbsp; The error is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;dojo.js:2072 Uncaught TypeError: Cannot read property 'parentNode' of null
at HTMLInputElement.d [as onfocusout] (dojo.js:2072)
at Object.trigger (jquery-3.3.1.js:8255)
at Object.simulate (jquery-3.3.1.js:8318)
at HTMLDocument.handler (jquery-3.3.1.js:8352)

&lt;/PRE&gt;&lt;P&gt;This can be reproduced by added jQuery and a focusout listener to any element outside the search input.&amp;nbsp; For example to any sample with a Search widget add:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;script src="https://code.jquery.com/jquery-3.3.1.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;SPAN&gt;&amp;lt;script&amp;gt;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;$(document).ready(() =&amp;gt; $('body').on('focusout', () =&amp;gt; {}));
&amp;lt;/script&amp;gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then click in the Search input control, and then click anywhere outside the Search input and check the console.&amp;nbsp; If you change the arcgisjs API version from 4.7 to 4.6 the error does not occur.&amp;nbsp;&amp;nbsp;The following jsfiddle example demonstrates this.&amp;nbsp; &lt;A href="http://jsfiddle.net/xrwfhc1n" rel="nofollow noopener noreferrer" target="_blank"&gt;http://jsfiddle.net/xrwfhc1n&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:09:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-in-onfocusout-in-4-7-causes-error/m-p/186217#M17301</guid>
      <dc:creator>KrisKaplan1</dc:creator>
      <dc:date>2021-12-12T16:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: Search widget in onfocusout in 4.7 causes error when used with jQuery</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-in-onfocusout-in-4-7-causes-error/m-p/186218#M17302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Same issue, and I am using the 4.8 release.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Sep 2018 17:56:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-in-onfocusout-in-4-7-causes-error/m-p/186218#M17302</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2018-09-07T17:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: Search widget in onfocusout in 4.7 causes error when used with jQuery</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-in-onfocusout-in-4-7-causes-error/m-p/186219#M17303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am seeing the same issue with 4.8.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Sep 2018 23:40:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-in-onfocusout-in-4-7-causes-error/m-p/186219#M17303</guid>
      <dc:creator>SamHall</dc:creator>
      <dc:date>2018-09-17T23:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: Search widget in onfocusout in 4.7 causes error when used with jQuery</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-in-onfocusout-in-4-7-causes-error/m-p/186220#M17304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp; This bug is affecting our production version of an application. Esri clients and the public have no way of fixing this. Please Escalate.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Oct 2018 14:35:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-in-onfocusout-in-4-7-causes-error/m-p/186220#M17304</guid>
      <dc:creator>williampreston</dc:creator>
      <dc:date>2018-10-26T14:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: Search widget in onfocusout in 4.7 causes error when used with jQuery</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-in-onfocusout-in-4-7-causes-error/m-p/186221#M17305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;FWIW: I have temporarily worked around this problem by just removing the onfocusout event handler from the esri-search__input element (after the first focus event to make sure it is after their event handlers are attached).&amp;nbsp; Obviously this removes any side effects this handler was performing, but so far iremoving this has not had any significant problems (definitely not as bad as the original error).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kris&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="color: #d4d4d4; background-color: #1e1e1e; font-weight: normal; font-size: 14px;"&gt;&lt;DIV&gt;&lt;SPAN style="color: #608b4e;"&gt;// With version 4.7 the search widget's onfocusout handler will throw an error&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #608b4e;"&gt;// whenever there is a jQuery onfocusout handler along the event path because of&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #608b4e;"&gt;// jQuery's event bubbling workaround for focusin/out events. So for now, just&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #608b4e;"&gt;// remove the Search widget's onfocusout handler to silence the error.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;const&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;handler&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;this&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;search&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: #dcdcaa;"&gt;on&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'search-focus'&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;event&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;=&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;handler&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: #dcdcaa;"&gt;remove&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;const&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;&amp;nbsp;s&lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;earchDiv&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: #dcdcaa;"&gt;querySelector&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'.esri-search__input'&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #c586c0;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;onfocusout&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;null&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; });&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Oct 2018 14:34:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-in-onfocusout-in-4-7-causes-error/m-p/186221#M17305</guid>
      <dc:creator>KrisKaplan1</dc:creator>
      <dc:date>2018-10-29T14:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: Search widget in onfocusout in 4.7 causes error when used with jQuery</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-in-onfocusout-in-4-7-causes-error/m-p/186222#M17306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;view.when(() =&amp;gt; {&lt;BR /&gt; document.querySelector('.esri-search__input').onfocusout = null;&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;your commented code is work for me. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Dec 2019 08:37:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/search-widget-in-onfocusout-in-4-7-causes-error/m-p/186222#M17306</guid>
      <dc:creator>kolinn</dc:creator>
      <dc:date>2019-12-18T08:37:44Z</dc:date>
    </item>
  </channel>
</rss>

