DEV Community

Daniel Pertu
Daniel Pertu

Posted on

Our desktop app has three media queries, none of them about width, and a rule that hides every scrollbar in it

Notifio is an Electron app that watches a rental search page and tells you when something new appears. You can get it from the download page, and when it starts it opens one window.

That window is resizable. Nothing in the code says otherwise, which in Electron means it is, and the only constraint on it is a minimum:

mainWindow = new BrowserWindow({
  width: 1000,
  height: 800,
  minWidth: 800,
  minHeight: 600,
  autoHideMenuBar: true,
  // ...
});
Enter fullscreen mode Exit fullscreen mode

So the UI has to work at any size from 800x600 up to a 6K display. I went looking for the code that handles that range and found that there is none.

Three media queries, and all three are about pointers

The renderer is 21 files and 3,144 lines of TSX, TS and CSS, built by Vite into one stylesheet. Here is every at-rule in that stylesheet:

grep -o "@media[^{]*{" public/assets/index-*.css | cat -n
Enter fullscreen mode Exit fullscreen mode
1  @media (hover:hover){
2  @media (hover:hover){
3  @media (hover:hover){
Enter fullscreen mode Exit fullscreen mode

Three media queries in 18,988 bytes of CSS, and all three are Tailwind's hover: variant protecting hover styles from touch devices. Not one of them mentions min-width or max-width. There are no sm:, md:, lg: or xl: prefixes anywhere in the renderer either:

sm:    0
md:    0
lg:    0
xl:    0
2xl:   0
Enter fullscreen mode Exit fullscreen mode

For comparison, the marketing site for the same product, built from the same Tailwind, ships three width queries in its stylesheet, at 40rem, 48rem and 64rem. The website is responsive. The app is not, and until I counted I would have told you both were.

What is there instead

The layout turns out to be held together by four things, none of which is a breakpoint.

One centred container, which is the only width constraint in the product:

<div className="mx-auto max-w-[960px] px-6 pb-20 pt-6">
Enter fullscreen mode Exit fullscreen mode

A small set of floors, which is where a narrow window would break if it broke:

min-w-[220px]    1
min-w-[104px]    1
min-w-[96px]     6
w-[84px]         1
h-[280px]        1
Enter fullscreen mode Exit fullscreen mode

And then the actual responsive strategy, which is per-element rather than per-viewport:

shrink-0            11
truncate             7
whitespace-nowrap    1
grid-cols-2          1
Enter fullscreen mode Exit fullscreen mode

Eleven things that refuse to shrink, seven that cut their text off with an ellipsis instead, and one two-column grid that stays two columns at every size. A max-w plus truncate is a real technique and it degrades gradually, which is why nobody noticed the absence of breakpoints: between 800px and 960px the column just stops growing, and under 960px the long strings start eliding. The failure mode is subtle rather than broken, so it never produced a bug report to fix.

I am not claiming the layout survives 800x600 intact, because I measured source rather than running it at that size, and a row with six 96px floors in it is exactly the sort of thing that overflows when you are not looking. What I can say is that nothing in the code is watching for it.

One thing scrolls, and nothing has a scrollbar

Then there is the part of this that is a decision rather than an absence. The renderer's global stylesheet opens with this:

@layer base {
  * {
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  *::-webkit-scrollbar {
    display: none;
  }
}
Enter fullscreen mode Exit fullscreen mode

That is the universal selector. Every scrollable element in the app, including the document itself, has no scrollbar. In a desktop app with a 600px minimum height and a 280px activity log in the middle of it, the document is going to scroll.

And exactly one element in 3,144 lines opts into scrolling of its own:

<div className="h-[280px] overflow-y-auto rounded-lg border border-[#262626] bg-black p-4">
Enter fullscreen mode Exit fullscreen mode

That is the activity log, the panel that caps itself at 200 lines. It is a fixed 280 pixels tall, it fills up while a search runs, and there is no visual indication that there is more of it above the top edge.

I did the same count on the website a fortnight ago and reached the same rule, hiding scrollbars on a marketing page where the browser's own chrome tells you the page is long. In a 960px-wide column inside an app window, the browser chrome is not there to tell you anything. This is the surface where that rule actually costs something, and it is the surface I copied it to first.

What the count is worth

Three facts came out of an afternoon of grepping, and all three were things I believed the opposite of:

believed                              measured
the app is responsive                 0 width media queries
the UI is one fixed-width layout      one max-w and 20 per-element floors
scrollbars are hidden on the website  hidden everywhere, app included
Enter fullscreen mode Exit fullscreen mode

The app's other UI numbers have a similar flavour: 37 buttons and 8 aria attributes in the same renderer, and a startup failure path that is a window made of a data URL sized 800x400, which is the smallest window the product can produce and the only one with no CSS in it at all.

The fix for the scrollbar rule is one line scoped to the log panel, and I will take it. The breakpoints are a bigger question, and the honest answer is that I do not know yet whether a 900px-wide Notifio looks wrong, because nobody has told me and I have never dragged the window there. What the app does once it is running is written up on the help page, which is the surface where people do tell me things.

Top comments (0)