<?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 Unselecting a graphic - how? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/unselecting-a-graphic-how/m-p/1520893#M85330</link>
    <description>&lt;P&gt;I've spent far too much time today trying to figure this out. In the 4.X API, how do you unselect a selected graphic? My specific issue is with a popup on a graphicsLayer where the graphic is not unselected when the popup is closed. FWIW, this would be my relevant code:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;			// Search for graphics at the clicked location
			theView.hitTest(screenPoint,{include:theGLayer}).then(function (response) {
				if (response.results.length) {					
						var theContent = app.plmf.graphicsLayerContent(response.results[0].graphic);
						var theTitle = "User Defined Project";
						
						theView.openPopup({title:theTitle, content:theContent, location: event.mapPoint});						
					//}
				}
			});
		});

		//Unselect the interactive project when the popup is closed
		reactiveUtils.watch(
		  // getValue function
		  () =&amp;gt; theView.popup.visible,
		  // callback
		  (visible) =&amp;gt; {
			  if (visible == true) {
				//Do Nothing
			  } else {
			    console.log('The popup is closed');
				theView.popup.clear();
			  }
		  });	&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 13 Aug 2024 22:01:16 GMT</pubDate>
    <dc:creator>SteveCole</dc:creator>
    <dc:date>2024-08-13T22:01:16Z</dc:date>
    <item>
      <title>Unselecting a graphic - how?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/unselecting-a-graphic-how/m-p/1520893#M85330</link>
      <description>&lt;P&gt;I've spent far too much time today trying to figure this out. In the 4.X API, how do you unselect a selected graphic? My specific issue is with a popup on a graphicsLayer where the graphic is not unselected when the popup is closed. FWIW, this would be my relevant code:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;			// Search for graphics at the clicked location
			theView.hitTest(screenPoint,{include:theGLayer}).then(function (response) {
				if (response.results.length) {					
						var theContent = app.plmf.graphicsLayerContent(response.results[0].graphic);
						var theTitle = "User Defined Project";
						
						theView.openPopup({title:theTitle, content:theContent, location: event.mapPoint});						
					//}
				}
			});
		});

		//Unselect the interactive project when the popup is closed
		reactiveUtils.watch(
		  // getValue function
		  () =&amp;gt; theView.popup.visible,
		  // callback
		  (visible) =&amp;gt; {
			  if (visible == true) {
				//Do Nothing
			  } else {
			    console.log('The popup is closed');
				theView.popup.clear();
			  }
		  });	&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2024 22:01:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/unselecting-a-graphic-how/m-p/1520893#M85330</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2024-08-13T22:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: Unselecting a graphic - how?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/unselecting-a-graphic-how/m-p/1520907#M85335</link>
      <description>&lt;P&gt;Looking at this sample here, if you call view.closePopup() the highlight is cleared.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=popup-editaction" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=popup-editaction&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2024 22:38:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/unselecting-a-graphic-how/m-p/1520907#M85335</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2024-08-13T22:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: Unselecting a graphic - how?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/unselecting-a-graphic-how/m-p/1521677#M85360</link>
      <description>&lt;P&gt;Hey Rene, thanks for responding. That sample works great for FeatureLayers but I'm dealing with a GraphicsLayer. Here's a CodePen using the Sketch Widget sample as a base:&lt;/P&gt;&lt;P&gt;&lt;A href="https://codepen.io/evtguy/pen/xxoPorp" target="_blank" rel="noopener"&gt;https://codepen.io/evtguy/pen/xxoPorp&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried my best to modify the sample to reflect the code in my actual application. Once you open the CodePen, here's what to do:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Use the Sketch tool to add a point.&lt;/LI&gt;&lt;LI&gt;Click anywhere in the map to deselect the graphic.&lt;/LI&gt;&lt;LI&gt;Now click on the added point graphic to display the popup.&lt;/LI&gt;&lt;LI&gt;Close the popup. The graphic remains selected.&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Wed, 14 Aug 2024 18:05:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/unselecting-a-graphic-how/m-p/1521677#M85360</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2024-08-14T18:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: Unselecting a graphic - how?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/unselecting-a-graphic-how/m-p/1521804#M85361</link>
      <description>&lt;P&gt;Ok, that's a little different. That's not a popup selection, that is the sketch selection because you are interacting with the sketch graphics layer. You can call cancel() on sketch to clear it when you close the popup.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch.html#cancel" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch.html#cancel&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2024 20:19:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/unselecting-a-graphic-how/m-p/1521804#M85361</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2024-08-14T20:19:40Z</dc:date>
    </item>
    <item>
      <title>Re: Unselecting a graphic - how?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/unselecting-a-graphic-how/m-p/1521805#M85362</link>
      <description>&lt;P&gt;Thanks. That appears to be what I wanted. That works in my application. Until it does something else unintended.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":face_with_tears_of_joy:"&gt;😂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2024 20:32:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/unselecting-a-graphic-how/m-p/1521805#M85362</guid>
      <dc:creator>SteveCole</dc:creator>
      <dc:date>2024-08-14T20:32:16Z</dc:date>
    </item>
  </channel>
</rss>

