I have two react components, one is to display the name and the circle and another is a sidebar. When I click the circle component, the sidebar will show. And when I click the outside of the circle component, the sidebar will be hidden.
I was set a onBlur to the circle component, so when I click outside of the element, the sidebar will be hidden.
However, there is a problem in this way that when I switch from Name A to Name B, the sidebar will be hidden first and then show.
Is there a way I can keep the sidebar open when I switch from Name A to Name B and the sidebar will be open if I click outside of the circle element without swtich?
The below is part of my code logic:
For the circle component:
const handleParticipantOnClick = () => {
dispatch(oepnSidebar())
}
const handleParticipantOnBlur = () => {
dispatch(closeSidebar())
}
<div onBlur={handleParticipantOnBlur} onClick={handleParticipantOnClick}>
<ProgressRing/>
</div>
The sidebar will be show/close based on the method dispatch, that action only update the open status of the sidebar.