Merge pull request #6367 from qiujun8023/fix/usage-stats-cards-mobile-horizontal-scroll

fix(frontend): prevent hidden cache tooltip from causing horizontal scroll on mobile
This commit is contained in:
Wesley Liddick
2026-08-31 11:18:03 +08:00
committed by GitHub
2 changed files with 23 additions and 1 deletions
@@ -36,7 +36,7 @@
/>
</svg>
<span
class="pointer-events-none absolute left-1/2 top-full z-30 mt-2 w-56 -translate-x-1/2 rounded-lg border border-gray-200 bg-white p-3 text-left text-xs text-gray-700 opacity-0 shadow-lg transition-opacity duration-150 group-hover:opacity-100 group-focus:opacity-100 dark:border-dark-600 dark:bg-dark-800 dark:text-dark-200"
class="pointer-events-none absolute left-1/2 top-full z-30 mt-2 hidden w-56 -translate-x-1/2 rounded-lg border border-gray-200 bg-white p-3 text-left text-xs text-gray-700 shadow-lg group-hover:block group-focus:block dark:border-dark-600 dark:bg-dark-800 dark:text-dark-200"
>
<span class="mb-2 block font-medium text-gray-900 dark:text-white">
{{ cacheDetailLabel() }}
@@ -64,4 +64,26 @@ describe('UsageStatsCards', () => {
expect(text).toContain('Cache Read')
expect(text).toContain('22')
})
it('keeps the cache tooltip out of the layout while it is hidden', () => {
const wrapper = mount(UsageStatsCards, {
props: {
stats,
},
global: {
stubs: {
Icon: true,
},
},
})
const tooltip = wrapper.findAll('span').find((el) => el.classes().includes('group-hover:block'))
expect(tooltip).toBeDefined()
// `opacity-0` hides the tooltip visually but keeps it in the layout, so its
// fixed width still widens the document and causes horizontal scrolling on
// narrow screens. `hidden` (display: none) takes it out of the flow.
expect(tooltip?.classes()).toContain('hidden')
expect(tooltip?.classes()).not.toContain('opacity-0')
})
})