fix: the app's player starts right under the bar on a wide window too

Merged
AL
10d ago
+34-3

Closes #168.

On a window at least 48rem wide, the app's player screen had 1.25rem of padding above the player. Nothing was drawn there, but it cost 20 px of the window's height. A book whose open chapter fit the window below the bar scrolled the window by those 20 px.

The padding is gone, so the player now starts right under the bar, as it already did on a phone. A message shown above the player has a top margin of the same 1.25rem instead, so it still sits where it did.

Changes

  • apps/demo/app/app.css: from 48rem up, the player screen's main has no padding-top. Its .message gets margin: 1.25rem 0 1rem in place of 0 0 1rem. The comment says why.
  • apps/demo/tests/app.test.ts: a new test opens the quiz and checks that the player is 0 px below the bar at 1000 and 600 px wide. It then opens a link that fails and checks that the message sits at least 16 px below the bar.

Testing

  • Before the fix: the live app in a Chromium tab at 1656×986, with an h5p-author Interactive Book open at its first chapter. The bar is 60 px high. The book is 930 px high at window heights of 760, 986 and 1200 px: its height comes from the chapter, not the window. The page scrolled 24 px. With the padding turned off, it scrolled 4 px, because this chapter is 4 px taller than the space below the bar.
  • The new test catches the bug: it fails with the CSS on main (at 1000px: expected 20 to be +0). It also fails with the padding removed but no margin on the message (expected 0 to be greater than or equal to 16).
  • With the fix: the new test passes in Chromium, Firefox and WebKit. The whole app test file (17 tests) passes in Chromium, and tsc passes for the demo.

Not verified

The installed window is not covered by the test. Chromium will not emulate display-mode, so the test runs in a tab. The rule this changes applies in both. The bug was found in an installed window, where turning the padding off in DevTools made the book fit.

Release

None needed. Only the demo's app changes, and Vercel deploys it when this merges.


Summary by cubic

Fixes the player screen's top padding on windows at least 48rem wide, so the player now starts right under the bar as it already did on a phone. The old 1.25rem of padding cost 20px of window height, which could make a book chapter that fit below the bar scroll the window instead. Closes #168.

The space now lives on the message shown above the player, keeping its position, and a new test verifies both the player's position at wide and narrow widths and the message's spacing.