Asset panel: double-click opens the tab, single click only selects (#71)
game-maker / suite (push) Failing after 8m11s
game-maker / suite (push) Failing after 8m11s
One rule for every asset type: a click on an asset row selects it, a double-click (or Enter, or creating it via +) opens its tab. Selection alone still switches tabs only for nodes, frames and template objects. - state.openAsset(id) = select + 'open' event; the editor maps the asset type to its tab via TAB_OF_ASSET. The two special clauses for state machine and shader assets in the selection handler are gone. - Creating via + and importing a texture from the picker open the tab; paste/drop of an image only selects. - 3 unit tests (event order, re-open of a selected asset, selection never fires open), 14 e2e checks in step 4. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
3da0ef1be2
commit
4d9c4982eb
7 files changed
+160
-15
No files matched your search
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Opening an asset (double-click, Enter, creating one) is selecting it plus a request for its tab.
|
||||
* The editor switches on `open`, never on `selection` alone – so the order and the "already
|
||||
* selected" case are what matter here.
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { CreateAssetCommand } from '../../src/core/commands/assetCommands';
|
||||
import { createEmptyProject } from '../../src/core/model/Project';
|
||||
import { EditorState } from '../../src/editor/state';
|
||||
|
||||
function setup(): { state: EditorState; assetId: string; events: string[] } {
|
||||
const state = new EditorState();
|
||||
state.loadProject(createEmptyProject('p', 'P'), 1);
|
||||
const create = new CreateAssetCommand('behavior', 'B');
|
||||
expect(state.execute(create)).toBe(true);
|
||||
const events: string[] = [];
|
||||
state.on('selection', () => events.push('selection'));
|
||||
state.on('open', () => events.push('open'));
|
||||
return { state, assetId: create.asset.id, events };
|
||||
}
|
||||
|
||||
describe('opening an asset', () => {
|
||||
it('selects it first and asks for the tab after, so the tab finds the selection in place', () => {
|
||||
const { state, assetId, events } = setup();
|
||||
state.openAsset(assetId);
|
||||
expect(state.selection).toEqual({ kind: 'asset', assetId });
|
||||
expect(events).toEqual(['selection', 'open']);
|
||||
});
|
||||
|
||||
it('still asks for the tab when the asset was selected already – a click did not open it', () => {
|
||||
const { state, assetId, events } = setup();
|
||||
state.select({ kind: 'asset', assetId });
|
||||
events.length = 0;
|
||||
state.openAsset(assetId);
|
||||
expect(events).toEqual(['open']);
|
||||
});
|
||||
|
||||
it('never fires on a plain selection', () => {
|
||||
const { state, assetId, events } = setup();
|
||||
state.select({ kind: 'asset', assetId });
|
||||
expect(events).toEqual(['selection']);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user