mirror of
https://github.com/stan-smith/FossFLOW.git
synced 2025-12-24 06:58:48 -05:00
fix: delete connectors by ID instead of index in scene
This fixes a critical bug where connectors weren't being properly removed from the scene when deleted, as the code was using array index instead of connector ID as the key.
This commit is contained in:
@@ -97,10 +97,8 @@ describe('connector reducer', () => {
|
||||
// Check connector is removed from model
|
||||
expect(result.model.views[0].connectors).toHaveLength(0);
|
||||
|
||||
// Check connector is removed from scene
|
||||
// NOTE: The implementation uses connector.index instead of connector.id
|
||||
// This appears to be a bug - it should delete by ID not index
|
||||
expect(result.scene.connectors[0]).toBeUndefined();
|
||||
// Check connector is removed from scene by ID
|
||||
expect(result.scene.connectors['connector1']).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should throw error when connector does not exist', () => {
|
||||
@@ -144,8 +142,7 @@ describe('connector reducer', () => {
|
||||
expect(result.model.views[0].connectors).toHaveLength(1);
|
||||
expect(result.model.views[0].connectors![0].id).toBe('connector2');
|
||||
expect(result.scene.connectors['connector2']).toBeDefined();
|
||||
// NOTE: Bug - implementation deletes by index (0) not ID
|
||||
expect(result.scene.connectors[0]).toBeUndefined();
|
||||
expect(result.scene.connectors['connector1']).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ export const deleteConnector = (
|
||||
|
||||
const newState = produce(state, (draft) => {
|
||||
draft.model.views[view.index].connectors?.splice(connector.index, 1);
|
||||
delete draft.scene.connectors[connector.index];
|
||||
delete draft.scene.connectors[id];
|
||||
});
|
||||
|
||||
return newState;
|
||||
|
||||
Reference in New Issue
Block a user