Skip to content

Commit

Permalink
fix(web): selection lost when update layer style etc. (#1192)
Browse files Browse the repository at this point in the history
  • Loading branch information
airslice authored Oct 23, 2024
1 parent 8b7e485 commit 270a26d
Show file tree
Hide file tree
Showing 6 changed files with 1,593 additions and 1,380 deletions.
4 changes: 2 additions & 2 deletions web/src/beta/features/Editor/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default ({ sceneId, projectId, tab }: Props) => {
currentProjectType,
handleProjectTypeChange,
handleLayerSelectFromUI,
handleCoreLayerSelectFromUI,
handleCoreLayerSelectFromMap,
handleSceneSettingSelectFromUI,
dataSourceLayerCreatorShown,
openDataSourceLayerCreator,
Expand Down Expand Up @@ -333,7 +333,7 @@ export default ({ sceneId, projectId, tab }: Props) => {
handleSketchFeatureCreate,
handleSketchFeatureUpdate,
handleIsVisualizerUpdate,
handleCoreLayerSelectFromUI,
handleCoreLayerSelectFromMap,
selectStoryPage,
selectWidgetArea,
mapPageValue,
Expand Down
4 changes: 3 additions & 1 deletion web/src/beta/features/Editor/hooks/useSketch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ export default ({

useEffect(() => {
// Workaround: in order to show the indicator of the selected sketch feature we need to unselect it first.
visualizerRef?.current?.layers.select(undefined);
if (pendingSketchSelectionRef.current) {
visualizerRef?.current?.layers.select(undefined);
}
// Workaround: we can't get an notice from core after nlsLayers got updated.
// Therefore we need to get and select the latest sketch feature manually delayed.
setTimeout(() => {
Expand Down
4 changes: 2 additions & 2 deletions web/src/beta/features/Editor/hooks/useUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default ({
]
);

const handleCoreLayerSelectFromUI = useCallback(
const handleCoreLayerSelectFromMap = useCallback(
(props: LayerSelectProps) => {
handleSceneSettingSelect(undefined);
handleCoreLayerSelect(props);
Expand Down Expand Up @@ -142,7 +142,7 @@ export default ({
currentProjectType,
handleProjectTypeChange,
handleLayerSelectFromUI,
handleCoreLayerSelectFromUI,
handleCoreLayerSelectFromMap,
handleSceneSettingSelectFromUI,
dataSourceLayerCreatorShown,
openDataSourceLayerCreator,
Expand Down
10 changes: 3 additions & 7 deletions web/src/beta/features/Editor/hooks/useUISelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,25 @@ export const useUISelection = ({
}) => {
const handleLayerStyleSelected = useCallback(
(layerStyleId: string) => {
handleLayerSelect(undefined);
handleSceneSettingSelect(undefined);
handleLayerStyleSelect(layerStyleId);
},
[handleLayerStyleSelect, handleSceneSettingSelect, handleLayerSelect]
[handleLayerStyleSelect]
);

const handleLayerSelected = useCallback(
(layerId: string) => {
handleLayerStyleSelect(undefined);
handleSceneSettingSelect(undefined);
handleLayerSelect({ layerId });
},
[handleLayerSelect, handleSceneSettingSelect, handleLayerStyleSelect]
[handleLayerSelect, handleSceneSettingSelect]
);

const handleSceneSettingSelected = useCallback(
(collection?: string) => {
handleLayerStyleSelect(undefined);
handleLayerSelect(undefined);
handleSceneSettingSelect(collection);
},
[handleLayerSelect, handleSceneSettingSelect, handleLayerStyleSelect]
[handleLayerSelect, handleSceneSettingSelect]
);

return {
Expand Down
4 changes: 2 additions & 2 deletions web/src/beta/features/Editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Editor: FC<Props> = ({ sceneId, projectId, workspaceId, tab }) => {
handleSketchFeatureCreate,
handleSketchFeatureUpdate,
handleIsVisualizerUpdate,
handleCoreLayerSelectFromUI,
handleCoreLayerSelectFromMap,
selectStoryPage,
selectWidgetArea,
mapPageValue,
Expand Down Expand Up @@ -92,7 +92,7 @@ const Editor: FC<Props> = ({ sceneId, projectId, workspaceId, tab }) => {
onSketchFeatureCreate={handleSketchFeatureCreate}
onSketchFeatureUpdate={handleSketchFeatureUpdate}
onVisualizerReady={handleIsVisualizerUpdate}
onCoreLayerSelect={handleCoreLayerSelectFromUI}
onCoreLayerSelect={handleCoreLayerSelectFromMap}
onCoreAPIReady={handleCoreAPIReady}
setSelectedStoryPageId={selectStoryPage}
selectWidgetArea={selectWidgetArea}
Expand Down
Loading

0 comments on commit 270a26d

Please sign in to comment.