mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-08 08:29:42 +02:00
fix(tabs): COD-358 re-query tab after rename cancel
This commit is contained in:
@@ -1788,11 +1788,11 @@ Object.assign(CodemanApp.prototype, {
|
|||||||
const session = this.sessions.get(sessionId);
|
const session = this.sessions.get(sessionId);
|
||||||
if (!session) return;
|
if (!session) return;
|
||||||
|
|
||||||
|
this._activeRename?.cancel();
|
||||||
|
|
||||||
const tabName = document.querySelector(`.tab-name[data-session-id="${sessionId}"]`);
|
const tabName = document.querySelector(`.tab-name[data-session-id="${sessionId}"]`);
|
||||||
if (!tabName) return;
|
if (!tabName) return;
|
||||||
|
|
||||||
this._activeRename?.cancel();
|
|
||||||
|
|
||||||
// Prevent tab re-renders from destroying the input while renaming
|
// Prevent tab re-renders from destroying the input while renaming
|
||||||
this._inlineRenameActive = true;
|
this._inlineRenameActive = true;
|
||||||
tabName.classList.add('tab-name-renaming');
|
tabName.classList.add('tab-name-renaming');
|
||||||
|
|||||||
@@ -459,6 +459,7 @@ describe('Inline rename input', () => {
|
|||||||
app: {
|
app: {
|
||||||
_activeRename: { sessionId: string } | null;
|
_activeRename: { sessionId: string } | null;
|
||||||
sessions: Map<string, { id: string; name: string }>;
|
sessions: Map<string, { id: string; name: string }>;
|
||||||
|
renderSessionTabs: () => void;
|
||||||
startInlineRename: (id: string) => void;
|
startInlineRename: (id: string) => void;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -475,10 +476,20 @@ describe('Inline rename input', () => {
|
|||||||
tabName.textContent = 'Second';
|
tabName.textContent = 'Second';
|
||||||
wrap.appendChild(tabName);
|
wrap.appendChild(tabName);
|
||||||
document.body.appendChild(wrap);
|
document.body.appendChild(wrap);
|
||||||
|
|
||||||
|
// Cancelling the first rename is allowed to repaint the tab list. Model
|
||||||
|
// that synchronously so a target captured before cancel() becomes stale.
|
||||||
|
const originalRenderSessionTabs = app.renderSessionTabs;
|
||||||
|
app.renderSessionTabs = () => {
|
||||||
|
const current = document.querySelector('.tab-name[data-session-id="second-id"]');
|
||||||
|
current?.replaceWith(current.cloneNode(true));
|
||||||
|
};
|
||||||
app.startInlineRename('second-id');
|
app.startInlineRename('second-id');
|
||||||
|
app.renderSessionTabs = originalRenderSessionTabs;
|
||||||
return {
|
return {
|
||||||
firstActive,
|
firstActive,
|
||||||
secondActive: app._activeRename?.sessionId,
|
secondActive: app._activeRename?.sessionId,
|
||||||
|
secondInputVisible: !!document.querySelector('.tab-name[data-session-id="second-id"] input.tab-rename-input'),
|
||||||
firstRenameClassActive:
|
firstRenameClassActive:
|
||||||
document.querySelector('.tab-name[data-session-id="first-id"]')?.classList.contains('tab-name-renaming') ??
|
document.querySelector('.tab-name[data-session-id="first-id"]')?.classList.contains('tab-name-renaming') ??
|
||||||
false,
|
false,
|
||||||
@@ -487,6 +498,7 @@ describe('Inline rename input', () => {
|
|||||||
|
|
||||||
expect(result.firstActive).toBe('first-id');
|
expect(result.firstActive).toBe('first-id');
|
||||||
expect(result.secondActive).toBe('second-id');
|
expect(result.secondActive).toBe('second-id');
|
||||||
|
expect(result.secondInputVisible).toBe(true);
|
||||||
expect(result.firstRenameClassActive).toBe(false);
|
expect(result.firstRenameClassActive).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user