Skip to content

Commit 027572a

Browse files
authored
Prevent state badge from drifting away from short resource names (#17645)
* Prevent state badge from drifting away from short resource names Stop .resource-name from growing to fill available space so the BadgeState indicator stays adjacent to the title text. Fixes #17479 * Add E2E test for state badge positioning on resource detail pages Verifies the state badge stays adjacent to the resource name for both short and long ConfigMap names by comparing bounding rects. Fixes #17479
1 parent 4f17de3 commit 027572a

2 files changed

Lines changed: 54 additions & 1 deletion

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { ConfigMapCreateEditPagePo } from '@/cypress/e2e/po/pages/explorer/config-map.po';
2+
3+
const localCluster = 'local';
4+
const namespace = 'default';
5+
const shortName = `a`;
6+
const longName = `e2e-test-long-configmap-name-that-should-truncate-with-ellipsis`;
7+
8+
describe('ConfigMap Detail Title Bar', { testIsolation: 'off', tags: ['@explorer2', '@adminUser'] }, () => {
9+
before(() => {
10+
cy.login();
11+
cy.createConfigMap(namespace, shortName);
12+
cy.createConfigMap(namespace, longName);
13+
});
14+
15+
it('should keep the state badge adjacent to a short resource name', () => {
16+
const detailPage = new ConfigMapCreateEditPagePo(localCluster, namespace, shortName);
17+
18+
detailPage.goTo();
19+
detailPage.waitForPage();
20+
21+
cy.get('.title-bar h1.title .resource-name').then(($name) => {
22+
cy.get('.title-bar h1.title .badge-state').then(($badge) => {
23+
const nameRect = $name[0].getBoundingClientRect();
24+
const badgeRect = $badge[0].getBoundingClientRect();
25+
const gap = badgeRect.left - nameRect.right;
26+
27+
expect(gap).to.be.lessThan(20);
28+
});
29+
});
30+
});
31+
32+
it('should keep the state badge adjacent to a long resource name', () => {
33+
const detailPage = new ConfigMapCreateEditPagePo(localCluster, namespace, longName);
34+
35+
detailPage.goTo();
36+
detailPage.waitForPage();
37+
38+
cy.get('.title-bar h1.title .resource-name').then(($name) => {
39+
cy.get('.title-bar h1.title .badge-state').then(($badge) => {
40+
const nameRect = $name[0].getBoundingClientRect();
41+
const badgeRect = $badge[0].getBoundingClientRect();
42+
const gap = badgeRect.left - nameRect.right;
43+
44+
expect(gap).to.be.lessThan(20);
45+
});
46+
});
47+
});
48+
49+
after('clean up', () => {
50+
cy.deleteRancherResource('v1', 'configmaps', `${ namespace }/${ shortName }`);
51+
cy.deleteRancherResource('v1', 'configmaps', `${ namespace }/${ longName }`);
52+
});
53+
});

shell/components/Resource/Detail/TitleBar/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ const showAdditionalActionButtons = computed(() => isArray(additionalActions));
204204
205205
.resource-name {
206206
display: inline-block;
207-
flex: 1 1 auto;
207+
flex: 0 1 auto;
208208
min-width: 0;
209209
white-space: nowrap;
210210
overflow-x: hidden;

0 commit comments

Comments
 (0)