Why some Icons, when fixed in the Dock, open as new Icons instead of on top of the existing Icon?

So, I created some .desktop files and put then in my .local/share/applications to open electron apps that I created with Nativefier. Those apps appear just fine in the applications menu, and I can fix them in the Dock, but when I open them, it opens as a new icon in the bar, as can be seen in the image bellow:

enter image description here

First icon in the image is the one that I add as Favorite, and when I click them, it opens the last one.

Is there a way for me to manipulate this behavior so the app opens in the same Icon that I marked as Favorite? As it works with other apps, like Nautilus, Tunderbird, even the Calculator in the screenshot.

Bellow is the .desktop file for the app shown in the screenshot:

[Desktop Entry]
Version=1.0
Name=Gather
Comment=Web App
Exec=/home/brenno/.webapp-manager/Gather6010-linux-x64/Gather6010
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/home/brenno/.local/share/ice/icons/Gather.png
Categories=GTK;Network;
MimeType=text/html;text/xml;application/xhtml_xml;
StartupWMClass=WebApp-Gather6010
StartupNotify=true
X-WebApp-URL=https://gather.town/app/S1LGHOTUkxcaTyin/Yosemite%20Labs

Thanks!


Crux here is to set your WMClass right in the desktop file. Open the application and check its WMClass as following. Run the command

xprop | grep WM_CLASS

then click the window of your application. If the class matches that provided in the .desktop file, the running instance will be represented as a white dot under the pinned icon.