Skip to content

Commit 8d77289

Browse files
authored
Refactor/workspace layout controller (#7768)
* refactor(activity): extract workspace layout into WorkspaceLayoutController Move the Home button workspace layout responsibilities (_findBlocks, repositionBlocks, setHomeContainers, _isFirstHomeClick toggle) out of activity.js into js/activity/workspace-layout-controller.js, following the same controller-extraction pattern used for GridController, SearchController and SelectionController. activity.js now instantiates the controller and keeps thin delegation stubs so existing callers are unaffected. Signed-off-by: Vanshika <pahalvanshikaa@gmail.com> * test(workspace-layout-controller): add behavioral test coverage Cover setup/wiring, findBlocks, the row/column _findBlocks toggle, repositionBlocks breakpoint handling, resize delegation, setHomeContainers, turtle reset behavior, and edge cases such as empty, single-block and large workspaces. Signed-off-by: Vanshika <pahalvanshikaa@gmail.com> * fix(workspace-layout-controller): guard findBlocks against a missing helpfulWheelDiv document.getElementById("helpfulWheelDiv") can return null; accessing .style on it would throw. The pre-extraction code had the same gap, so guard it now that the code is being touched. Signed-off-by: Vanshika <pahalvanshikaa@gmail.com> * refactor(workspace-layout-controller): bind delegation stubs and reduce test duplication Use controller.method.bind(controller) instead of arrow-function wrappers for the activity-level delegation stubs, and add a setupActivity() test helper to collapse the repeated makeActivity()+setupWorkspaceLayoutController() pairing across the suite. Also correct a misleading comment (the DOM lookup isn't cached, it's just done once). Signed-off-by: Vanshika <pahalvanshikaa@gmail.com> --------- Signed-off-by: Vanshika <pahalvanshikaa@gmail.com>
1 parent da3c268 commit 8d77289

5 files changed

Lines changed: 1088 additions & 368 deletions

File tree

js/__tests__/activity_toolbar_integration.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ const loadActivityClass = () => {
9797
helpfulSearchDiv: null
9898
})),
9999
setupSearchController: jest.fn(),
100+
setupWorkspaceLayoutController: jest.fn(),
100101
hideDOMLabel: jest.fn(),
101102
setupActivityRecorder: jest.fn(),
102103
setupActivityAbcParser: jest.fn(),

0 commit comments

Comments
 (0)