fix(editor): Fix issue for blinking/jumping UI when switching projects (#22256)

This commit is contained in:
Dawid Myslak 2025-11-25 10:37:09 +01:00 committed by GitHub
parent 254a53e7bb
commit 6185550971
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 7 deletions

View File

@ -168,6 +168,22 @@ describe('ProjectHeader', () => {
expect(getByTestId('project-subtitle')).toHaveTextContent(personalSubtitle);
});
it('Personal: should render the correct title when currentProject is null but personalProject exists', async () => {
settingsStore.isDataTableFeatureEnabled = false;
vi.spyOn(projectPages, 'isOverviewSubPage', 'get').mockReturnValue(false);
vi.spyOn(projectPages, 'isSharedSubPage', 'get').mockReturnValue(false);
const { getByTestId, rerender } = renderComponent();
const personalSubtitle = 'Workflows and credentials owned by you';
projectsStore.currentProject = null;
projectsStore.personalProject = { type: ProjectTypes.Personal } as Project;
await rerender({});
expect(getByTestId('project-name')).toHaveTextContent('Personal');
expect(getByTestId('project-subtitle')).toHaveTextContent(personalSubtitle);
});
it('Team project: should render the correct title and no subtitle if there is no description', async () => {
vi.spyOn(projectPages, 'isOverviewSubPage', 'get').mockReturnValue(false);
vi.spyOn(projectPages, 'isSharedSubPage', 'get').mockReturnValue(false);

View File

@ -59,12 +59,20 @@ const headerIcon = computed((): IconOrEmoji => {
}
});
const homeProject = computed(() => projectsStore.currentProject ?? projectsStore.personalProject);
const isPersonalProject = computed(() => {
return homeProject.value?.type === ProjectTypes.Personal;
});
const projectName = computed(() => {
if (!projectsStore.currentProject) {
if (projectPages.isSharedSubPage) {
return i18n.baseText('projects.header.shared.title');
} else if (projectPages.isOverviewSubPage) {
return i18n.baseText('projects.menu.overview');
} else if (isPersonalProject.value) {
return i18n.baseText('projects.menu.personal');
}
return null;
} else if (projectsStore.currentProject.type === ProjectTypes.Personal) {
@ -91,12 +99,6 @@ const showSettings = computed(
projectsStore.currentProject?.type === ProjectTypes.Team,
);
const homeProject = computed(() => projectsStore.currentProject ?? projectsStore.personalProject);
const isPersonalProject = computed(() => {
return homeProject.value?.type === ProjectTypes.Personal;
});
const showFolders = computed(() => {
return (
settingsStore.isFoldersFeatureEnabled &&
@ -475,7 +477,6 @@ const onSelect = (action: string) => {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding-bottom: var(--spacing--lg);
min-height: var(--spacing--3xl);
}