Skip to content

Commit

Permalink
Fix topbar submenu width on mobile/tablet (#1047)
Browse files Browse the repository at this point in the history
* Fix topbar submenu width on tablet

* Add Playwright test

* Use better selector

* nit

---------

Co-authored-by: Chenlei Hu <chenlei.hu@mail.utoronto.ca>
  • Loading branch information
christian-byrne and huchenlei authored Sep 30, 2024
1 parent 6ea5fea commit 224c008
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions browser_tests/ComfyPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ class Topbar {
.allInnerTexts()
}

async openSubmenuMobile() {
await this.page.locator('.p-menubar-mobile .p-menubar-button').click()
}

async getMenuItem(itemLabel: string): Promise<Locator> {
return this.page.locator(`.p-menubar-item-label:text-is("${itemLabel}")`)
}
Expand Down
15 changes: 15 additions & 0 deletions browser_tests/menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,21 @@ test.describe('Menu', () => {
})
})

test.describe('Topbar submmenus', () => {
test('@mobile Items fully visible on mobile screen width', async ({
comfyPage
}) => {
await comfyPage.menu.topbar.openSubmenuMobile()
const topLevelMenuItem = comfyPage.page
.locator('a.p-menubar-item-link')
.first()
const isTextCutoff = await topLevelMenuItem.evaluate((el) => {
return el.scrollWidth > el.clientWidth
})
expect(isTextCutoff).toBe(false)
})
})

// Only test 'Top' to reduce test time.
// ['Bottom', 'Top']
;['Top'].forEach(async (position) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/topbar/TopMenubar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
:model="items"
class="top-menubar border-none p-0 bg-transparent"
:pt="{
rootList: 'gap-0 flex-nowrap'
rootList: 'gap-0 flex-nowrap w-auto'
}"
/>
<Divider layout="vertical" class="mx-2" />
Expand Down

0 comments on commit 224c008

Please sign in to comment.