@@ -44,7 +44,13 @@ import {
4444 type UseStateBooleanReturn ,
4545} from '@gridsuite/commons-ui' ;
4646import { isNodeBuilt , isNodeEdited , isSameNodeAndBuilt } from '../graph/util/model-functions' ;
47- import { openDiagram , resetMapEquipment , setMapDataLoading , setReloadMapNeeded } from '../../redux/actions' ;
47+ import {
48+ openDiagram ,
49+ resetMapEquipment ,
50+ setMapDataLoading ,
51+ setMapState ,
52+ setReloadMapNeeded ,
53+ } from '../../redux/actions' ;
4854import GSMapEquipments from './gs-map-equipments' ;
4955import { Box , Button , LinearProgress , Tooltip , useTheme } from '@mui/material' ;
5056import { EQUIPMENT_TYPES } from '../utils/equipment-types' ;
@@ -549,10 +555,15 @@ export const NetworkMapPanel = forwardRef<NetworkMapPanelRef, NetworkMapPanelPro
549555 updateSubstationsTemporaryGeoData ,
550556 updateLinesTemporaryGeoData ,
551557 ] ) ;
552- const handleFilteredNominalVoltagesChange = useCallback < NominalVoltageFilterProps [ 'onChange' ] > ( ( newValues ) => {
553- setFilteredNominalVoltages ( newValues ) ;
554- setNominalVoltages ( newValues ) ;
555- } , [ ] ) ;
558+ const handleFilteredNominalVoltagesChange = useCallback < NominalVoltageFilterProps [ 'onChange' ] > (
559+ ( newValues ) => {
560+ setFilteredNominalVoltages ( newValues ) ;
561+ setNominalVoltages ( newValues ) ;
562+ // Store filters in Redux immediately
563+ dispatch ( setMapState ( { filteredNominalVoltages : newValues } ) ) ;
564+ } ,
565+ [ dispatch ]
566+ ) ;
556567 // loads all root node geo-data then saves them in redux
557568 // it will be considered as the source of truth to check whether we need to fetch geo-data for a specific equipment or not
558569 const loadRootNodeGeoData = useCallback ( ( ) => {
@@ -863,6 +874,11 @@ export const NetworkMapPanel = forwardRef<NetworkMapPanelRef, NetworkMapPanelPro
863874 setIsRootNodeGeoDataLoaded ( false ) ;
864875 setHasInitializedFilters ( false ) ;
865876 dispatch ( resetMapEquipment ( ) ) ;
877+ if ( refIsMapManualRefreshEnabled . current ) {
878+ dispatch ( setReloadMapNeeded ( true ) ) ; // Trigger map reload in manual refresh mode
879+ setHasInitializedFilters ( false ) ;
880+ setFilteredNominalVoltages ( [ ] ) ;
881+ }
866882 return ;
867883 }
868884 if ( disabled ) {
@@ -872,6 +888,16 @@ export const NetworkMapPanel = forwardRef<NetworkMapPanelRef, NetworkMapPanelPro
872888 if ( isNodeEdited ( previousCurrentNode , currentNode ) ) {
873889 return ;
874890 }
891+
892+ // when current node changes (and it's not just a rename), set reload needed
893+ if (
894+ previousCurrentNode &&
895+ previousCurrentNode . id !== currentNode ?. id &&
896+ refIsMapManualRefreshEnabled . current
897+ ) {
898+ dispatch ( setReloadMapNeeded ( true ) ) ;
899+ }
900+
875901 // when switching of root network, networkModificationTree takes some time to load
876902 // we need to wait for the request to respond to load data, in order to have up to date nodes build status
877903 if ( ! isNetworkModificationTreeUpToDate ) {
@@ -892,6 +918,9 @@ export const NetworkMapPanel = forwardRef<NetworkMapPanelRef, NetworkMapPanelPro
892918 if ( ! isMapEquipmentsInitialized ) {
893919 // load default node map equipments
894920 loadMapEquipments ( ) ;
921+ // Reset filters when loading new map equipments
922+ setHasInitializedFilters ( false ) ;
923+ setFilteredNominalVoltages ( [ ] ) ;
895924 }
896925 if ( ! isRootNodeGeoDataLoaded ) {
897926 // load root node geodata
@@ -1206,7 +1235,7 @@ export const NetworkMapPanel = forwardRef<NetworkMapPanelRef, NetworkMapPanelPro
12061235 // programmatically
12071236 // - changing visible when the map provider is changed in the settings because
12081237 // it causes a render with the map container having display:none
1209- onManualRefreshClick = { loadMapManually }
1238+ onManualRefreshClick = { isNetworkModificationTreeUpToDate ? loadMapManually : undefined }
12101239 triggerMapResizeOnChange = { [ visible ] }
12111240 renderPopover = { renderLinePopover }
12121241 mapLibrary = { networkVisuParams . mapParameters . mapBaseMap }
0 commit comments