I have created a custom widget that retrieves the information from a parcel layer when user clicks on the parcel. The issue I am facing is that when I switch to other widgets in the application (for example measurement) which requires clicking on the map, my custom widget is still active. It keeps on giving me the active state of both - Custom widget and Measurement widget.
I am trying to get the active state of widget. I am taking lot of help from AI softwares like chatGPT etc but it is always showing props.active as undefined. ChatGPT is suggesting that there may be problem in installation. I was working in developer edition 1.16 and now to resolve this issue, I reinstalled v 1.16 and still I am getting the same issue.
I am sure lot of people may have created custom widgets and successfully made its functionality active only when the widget is in focus. I would appreciate if someone can proved me some help.
Here is the sample code of my test widget.tsx file
import { React, AllWidgetProps } from 'jimu-core';
const Widget = (props: AllWidgetProps<any>) => {
console.log("Widget Mounted");
console.log("Widget ID:", props.id);
console.log("Is this widget active?", props.active ?? "Not provided");
return (
<div>
<h3>Active Test Widget</h3>
<p>Widget ID: {props.id}</p>
<p>Is Active: {props.active ? "Yes" : "No"}</p>
</div>
);
};
export default Widget;