<?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 Highlight resets when update() is called in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Highlight-resets-when-update-is-called/m-p/4880983#M63859</link>
    <description>&lt;P&gt;Hi, I am having trouble synchronising selections between visuals.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem comes with making a selection in my visual after making a selection in another.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Interacting solely with the other visual works fine, the update function in mine gets called and the selection gets synchronised by reading the highlight properties. The problem comes with then making a selection in my custom visual. If I select something, update() gets called immediately after containing no highlights at all. This then resets the selection. Only clicking again will the selection stay as update doesn't get called again.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure how to solve this.&amp;nbsp;I can't find a way to ignore the problematic update or get the update to contain the selection that was just made, though I'm not sure either are on the right track.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Nov 2025 12:02:47 GMT</pubDate>
    <dc:creator>YCbCr</dc:creator>
    <dc:date>2025-11-20T12:02:47Z</dc:date>
    <item>
      <title>Highlight resets when update() is called</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Highlight-resets-when-update-is-called/m-p/4880983#M63859</link>
      <description>&lt;P&gt;Hi, I am having trouble synchronising selections between visuals.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem comes with making a selection in my visual after making a selection in another.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Interacting solely with the other visual works fine, the update function in mine gets called and the selection gets synchronised by reading the highlight properties. The problem comes with then making a selection in my custom visual. If I select something, update() gets called immediately after containing no highlights at all. This then resets the selection. Only clicking again will the selection stay as update doesn't get called again.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure how to solve this.&amp;nbsp;I can't find a way to ignore the problematic update or get the update to contain the selection that was just made, though I'm not sure either are on the right track.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Nov 2025 12:02:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Highlight-resets-when-update-is-called/m-p/4880983#M63859</guid>
      <dc:creator>YCbCr</dc:creator>
      <dc:date>2025-11-20T12:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: Highlight resets when update() is called</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Highlight-resets-when-update-is-called/m-p/4881743#M63874</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Highlight resets when update() is called after my visual selection&lt;BR /&gt;This is expected behavior in the custom visuals API, and it comes from how cross-highlighting vs. your own selection are represented:&lt;/P&gt;
&lt;P&gt;When another visual drives the selection, the host can send a highlights array in your dataView (if your visual declares supportsHighlight: true). You read those highlights and render a partial emphasis. Microsoft Learn+1&lt;/P&gt;
&lt;P&gt;When your visual drives the selection, the selection state is not echoed back via the highlights array. Instead, the host triggers an update() (often with a data query) and expects you to restore the selection using the Selection Manager (ISelectionManager). In other words: highlights are for cross-visual input, selection manager is for your visual’s own state. Microsoft Learn&lt;/P&gt;
&lt;P&gt;So what you’re observing—first click selects, host fires update(), highlights are empty and your selection appears “lost” until a second click—usually means the visual is clearing its own selection because it only trusts highlights and isn’t restoring from the Selection Manager.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;What to change&lt;BR /&gt;Declare highlight support (for cross-visual)&lt;BR /&gt;In capabilities.json, keep:&lt;BR /&gt;"dataViewMappings": [ ... ],&lt;BR /&gt;"supportsHighlight": true&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Then use categorical.values[i].highlights only when present (that means another visual is selecting).&lt;/P&gt;
&lt;P&gt;Own your selection state (for self-selection)&lt;/P&gt;
&lt;P&gt;Use ISelectionManager to store and restore selected ISelectionIds.&lt;/P&gt;
&lt;P&gt;On click in your visual:&lt;/P&gt;
&lt;P&gt;await selectionManager.select(selectionId, multiSelect);&lt;BR /&gt;// Optionally set a guard flag here (see #3)&lt;/P&gt;
&lt;P&gt;In update(options), don’t clear selection just because highlights is null/undefined. Instead:&lt;/P&gt;
&lt;P&gt;If highlights exist → render cross-highlight.&lt;/P&gt;
&lt;P&gt;Else if selectionManager.getSelectionIds().length &amp;gt; 0 → render your own selected points (re-apply the visual styling based on those IDs).&lt;/P&gt;
&lt;P&gt;Else → render default (no selection).&lt;BR /&gt;Documentation for the Selection API: Microsoft Learn+1&lt;/P&gt;
&lt;P&gt;Ignore the “echo” update caused by your own click (optional but helpful)&lt;BR /&gt;The host often re-queries and calls update() right after your select(). Add a short-lived guard flag so your next update() doesn’t wipe your in-memory selection while the new dataView is arriving.&lt;/P&gt;
&lt;P&gt;Example pattern:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;private skipNextUpdate = false;&lt;/P&gt;
&lt;P&gt;onDataPointClick(selectionId) {&lt;BR /&gt;this.skipNextUpdate = true;&lt;BR /&gt;selectionManager.select(selectionId).then(() =&amp;gt; {&lt;BR /&gt;// let the host call update()&lt;BR /&gt;});&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;public update(options: VisualUpdateOptions) {&lt;BR /&gt;if (this.skipNextUpdate) {&lt;BR /&gt;this.skipNextUpdate = false;&lt;BR /&gt;// Repaint using selectionManager.getSelectionIds()&lt;BR /&gt;this.renderFromSelectionManagerOrHighlights(options);&lt;BR /&gt;return;&lt;BR /&gt;}&lt;BR /&gt;this.renderFromSelectionManagerOrHighlights(options);&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Branch logic on update type (optional)&lt;BR /&gt;You can check options.type (e.g., VisualUpdateType.Data, Resize, Style) to decide how aggressively to rebind or redraw. This won’t bring back highlights, but it helps reduce flicker and accidental clears.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT color="#800000"&gt;Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Nov 2025 06:29:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Highlight-resets-when-update-is-called/m-p/4881743#M63874</guid>
      <dc:creator>johnbasha33</dc:creator>
      <dc:date>2025-11-21T06:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Highlight resets when update() is called</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Highlight-resets-when-update-is-called/m-p/4883376#M63892</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1408455"&gt;@YCbCr&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/585150"&gt;@johnbasha33&lt;/a&gt;&amp;nbsp;for your response to the query.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Has your issue been resolved?&lt;BR /&gt;If the response provided by the community member addressed your query, could you please confirm? It helps us ensure that the solutions provided are effective and beneficial for everyone.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Nov 2025 04:06:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Highlight-resets-when-update-is-called/m-p/4883376#M63892</guid>
      <dc:creator>v-sgandrathi</dc:creator>
      <dc:date>2025-11-24T04:06:56Z</dc:date>
    </item>
  </channel>
</rss>

