Skip to content

Commit c58ef36

Browse files
committed
Adding resetting view when auto arranging.
1 parent b27972b commit c58ef36

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

src/reactviews/pages/SchemaDesigner/schemaDesignerStateProvider.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export interface SchemaDesignerContextProps
4848
}>;
4949
closeDesigner: () => void;
5050
resetUndoRedoState: () => void;
51+
resetView: () => void;
5152
isInitialized: boolean;
5253
}
5354

@@ -397,6 +398,14 @@ const SchemaDesignerStateProvider: React.FC<SchemaDesignerProviderProps> = ({ ch
397398
eventBus.emit("updateUndoRedoState", stateStack.canUndo(), stateStack.canRedo());
398399
};
399400

401+
function resetView() {
402+
setTimeout(async () => {
403+
await reactFlow.fitView({
404+
nodes: reactFlow.getNodes().filter((node) => node.hidden !== true),
405+
});
406+
}, 0);
407+
}
408+
400409
return (
401410
<SchemaDesignerContext.Provider
402411
value={{
@@ -425,6 +434,7 @@ const SchemaDesignerStateProvider: React.FC<SchemaDesignerProviderProps> = ({ ch
425434
isInitialized,
426435
closeDesigner,
427436
resetUndoRedoState,
437+
resetView,
428438
}}>
429439
{children}
430440
</SchemaDesignerContext.Provider>

src/reactviews/pages/SchemaDesigner/toolbar/autoArrangeButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export function AutoArrangeButton() {
3333
const generateComponenets = flowUtils.generatePositions(nodes, edges);
3434
reactFlow.setNodes(generateComponenets.nodes);
3535
reactFlow.setEdges(generateComponenets.edges);
36+
context.resetView();
3637
};
3738
if (!context) {
3839
return undefined;

src/reactviews/pages/SchemaDesigner/toolbar/filterTablesButton.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,6 @@ export function FilterTablesButton() {
3131
const [selectedTables, setSelectedTables] = useState<string[]>([]);
3232
const [isFilterMenuOpen, setIsFilterMenuOpen] = useState(false);
3333

34-
function resetView() {
35-
setTimeout(async () => {
36-
await reactFlow.fitView({
37-
nodes: reactFlow.getNodes().filter((node) => node.hidden !== true),
38-
});
39-
}, 0);
40-
}
41-
4234
function loadTables() {
4335
// Update the selected tables based on the current nodes
4436
const nodes = reactFlow.getNodes();
@@ -62,7 +54,6 @@ export function FilterTablesButton() {
6254
hidden: false,
6355
});
6456
});
65-
resetView();
6657
} else {
6758
nodes.forEach((node) => {
6859
const tableName = `${node.data.schema}.${node.data.name}`;
@@ -201,7 +192,7 @@ export function FilterTablesButton() {
201192
selectedItems={selectedTables}
202193
onSelectionChange={(_e, data) => {
203194
setSelectedTables(data.selectedItems as string[]);
204-
resetView();
195+
context.resetView();
205196
}}>
206197
{renderListItems()}
207198
</List>
@@ -219,7 +210,7 @@ export function FilterTablesButton() {
219210
style={{}}
220211
onClick={async () => {
221212
setSelectedTables([]);
222-
resetView();
213+
context.resetView();
223214
}}
224215
appearance="subtle"
225216
icon={<FluentIcons.DismissRegular />}>

0 commit comments

Comments
 (0)