Description
When deleting a screen or project in the UIKit Playground, the activeScreen and activeProject state values are not correctly updated, causing the UI to reflect stale or invalid state after the deletion.
Steps to Reproduce
- Open the UIKit Playground.
- Create a project with two or more screens.
- Make one of the screens the active screen.
- Delete the currently active screen.
- Observe that
activeScreen does not update to a valid remaining screen.
- Delete all screens from a project.
- Observe that the project persists in state as an empty entry instead of being removed.
Expected Behavior
- After deleting the active screen,
activeScreen should automatically update to point to a valid remaining screen.
- After deleting the active project,
activeProject should update accordingly.
- If all screens in a project are deleted, the project itself should be automatically removed from state.
- The UI should always reflect accurate, current state after any deletion operation.
Actual Behavior
activeScreen and activeProject continue to reference the deleted item or resolve incorrectly.
- Empty projects (with no remaining screens) persist in state after their last screen is deleted.
- The UI does not update correctly, leaving the user with a broken or inconsistent view.
Root Cause (Investigated)
The reducer recalculates active state before removing the target screen from the list. This means the recalculation runs on stale data — the deleted screen is still present during index resolution — resulting in incorrect activeScreen and activeProject values.
Environment
- App: UIKit Playground
- Area: State management / reducer logic
Additional Context
No external dependencies are affected. The issue is isolated to the deletion reducer logic within the Playground.
Description
When deleting a screen or project in the UIKit Playground, the
activeScreenandactiveProjectstate values are not correctly updated, causing the UI to reflect stale or invalid state after the deletion.Steps to Reproduce
activeScreendoes not update to a valid remaining screen.Expected Behavior
activeScreenshould automatically update to point to a valid remaining screen.activeProjectshould update accordingly.Actual Behavior
activeScreenandactiveProjectcontinue to reference the deleted item or resolve incorrectly.Root Cause (Investigated)
The reducer recalculates active state before removing the target screen from the list. This means the recalculation runs on stale data — the deleted screen is still present during index resolution — resulting in incorrect
activeScreenandactiveProjectvalues.Environment
Additional Context
No external dependencies are affected. The issue is isolated to the deletion reducer logic within the Playground.