mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-20 09:09:35 +02:00
fix(tiles): a claim that lands mid-drag lets the dragged tile go (#584 merge-time fix)
_onTileAdoptedElsewhere acted only on a tear-off, a pending tear-off or a drag that just ended. A header drag carries the tile id even when this window has Detach Tiles off (no tear-off), so another window could dock the tile and its claim could arrive before this drag ended; the tile then stayed here as well. The header drag (_draggedTileId) now counts as dragging too. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
3975089af3
commit
48e91fc1d9
2 files changed
+13
-1
No files matched your search
@@ -3004,7 +3004,9 @@ Object.assign(CodemanApp.prototype, {
|
||||
*/
|
||||
_onTileAdoptedElsewhere(sessionId) {
|
||||
const recent = this._lastTileDrag;
|
||||
const dragging = this._tileTearOff?.id === sessionId;
|
||||
// A header drag counts even without a tear-off (Detach Tiles off here): the
|
||||
// other window can take the tile before this drag ends.
|
||||
const dragging = this._tileTearOff?.id === sessionId || this._draggedTileId === sessionId;
|
||||
const pending = this._tileTearOffPending?.id === sessionId;
|
||||
const justEnded = recent?.id === sessionId && Date.now() - recent.at < TILE_ADOPT_WINDOW_MS;
|
||||
if (!dragging && !pending && !justEnded) return false;
|
||||
|
||||
@@ -316,6 +316,16 @@ describe('another window docking the tile this one dragged', () => {
|
||||
expect(localStore.get('codeman:tile-grid')).toBe(docked);
|
||||
});
|
||||
|
||||
it('a claim that lands mid-drag lets the tile go, with no tear-off here (Detach Tiles off)', () => {
|
||||
// The tile's id rides every header drag, so a window with Detach Tiles on can
|
||||
// dock it while this one has the setting off; its claim can beat the dragend.
|
||||
const app = openGrid(FOUR, { detach: false });
|
||||
startDrag('s-b');
|
||||
expect(app._tileTearOff ?? null).toBeNull();
|
||||
app._onWindowMessage({ type: 'tile-adopted', id: 's-b', by: 'c-there' });
|
||||
expect(app._tileGrid.ids).toEqual(['s-a', 's-c', 's-d']);
|
||||
});
|
||||
|
||||
it('a claim for a tile this window did not drag, or one it dragged long ago, is ignored', () => {
|
||||
const app = openGrid(FOUR);
|
||||
app._onWindowMessage({ type: 'tile-adopted', id: 's-b', by: 'c-there' });
|
||||
|
||||
Reference in new issue
Block a user