@@ -11,7 +11,7 @@ import 'common/Map/Map.scss';
11
11
12
12
import { useModal } from 'common/BootstrapSNCF/ModalSNCF' ;
13
13
import { LoaderState } from 'common/Loader' ;
14
- import { loadDataModel , updateTotalsIssue } from 'reducers/editor' ;
14
+ import { loadDataModel , selectLayers , updateTotalsIssue } from 'reducers/editor' ;
15
15
import { updateInfraID } from 'reducers/osrdconf' ;
16
16
import { updateViewport , Viewport } from 'reducers/map' ;
17
17
import { getInfraID } from 'reducers/osrdconf/selectors' ;
@@ -27,7 +27,6 @@ import {
27
27
EditorContextType ,
28
28
ExtendedEditorContextType ,
29
29
FullTool ,
30
- ReadOnlyEditorContextType ,
31
30
Reducer ,
32
31
} from './tools/editorContextTypes' ;
33
32
import { switchProps } from './tools/switchProps' ;
@@ -182,6 +181,13 @@ const Editor: FC = () => {
182
181
// eslint-disable-next-line react-hooks/exhaustive-deps
183
182
} , [ toolAndState . tool ] ) ;
184
183
184
+ useEffect ( ( ) => {
185
+ const layersList = toolAndState . tool . requiredLayers
186
+ ? new Set ( [ ...editorState . editorLayers , ...toolAndState . tool . requiredLayers ] )
187
+ : editorState . editorLayers ;
188
+ dispatch ( selectLayers ( layersList ) ) ;
189
+ } , [ toolAndState . tool ] ) ;
190
+
185
191
return (
186
192
< EditorContext . Provider value = { extendedContext as EditorContextType < unknown > } >
187
193
< main
@@ -191,7 +197,7 @@ const Editor: FC = () => {
191
197
< div className = "tool-box bg-primary" >
192
198
{ Object . values ( TOOL_TYPES ) . map ( ( toolType : TOOL_TYPES ) => {
193
199
const tool = TOOLS [ toolType ] ;
194
- const { id, icon : IconComponent , labelTranslationKey, isDisabled } = tool ;
200
+ const { id, icon : IconComponent , labelTranslationKey } = tool ;
195
201
const label = t ( labelTranslationKey ) ;
196
202
197
203
return (
@@ -206,10 +212,6 @@ const Editor: FC = () => {
206
212
onClick = { ( ) => {
207
213
switchTool ( { toolType, toolState : { } } ) ;
208
214
} }
209
- disabled = {
210
- // TODO: clarify the type of extendedContext
211
- isDisabled && isDisabled ( extendedContext as ReadOnlyEditorContextType < any > )
212
- }
213
215
>
214
216
< span className = "sr-only" > { label } </ span >
215
217
< IconComponent />
0 commit comments