facebook / facebook/docusaurus

@media rule thresholds do not account for browser font size setting

オープン
#9,390 コメント 15 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug domain: a11y
主要言語
TypeScript
スター
66.2k
フォーク
10k
平均マージ
1日 3時間
マージ済み PR(30日)
52

説明

### Have you read the Contributing Guidelines on issues?

- [X] I have read the [Contributing Guidelines on issues](https://github.com/facebook/docusaurus/blob/main/CONTRIBUTING.md#issues).

### Prerequisites

- [X] I'm using the latest version of Docusaurus.
- [X] I have tried the `npm run clear` or `yarn clear` command.
- [X] I have tried `rm -rf node_modules yarn.lock package-lock.json` and re-installing packages.
- [X] I have tried creating a repro with https://new.docusaurus.io.
- [X] I have read the console error message carefully (if applicable).

### Description

Most things in docusaurus scale with `rem` units, but the thresholds for `@media` rules are set in `px`. Which means setting a large font size in the browser effectively "zooms in" the page, but the `@media` rules do not trigger like they would with actual zoom.

Screenshots below are from the page https://docusaurus.io/docs/styling-layout with the same zoom level (100%) and viewport size (~1000px). The large font size breaks the layout.

| normal font size|large font size |
|----|----|
|![image_2023-10-10_18-07-29](https://github.com/facebook/docusaurus/assets/36504423/58db7fe0-7ddc-425d-827a-e4bbbb4bf3c7)|![image_2023-10-10_18-07-29 (2)](https://github.com/facebook/docusaurus/assets/36504423/6d85cb60-bcba-4389-bb9e-e40695304f29)|

### Reproducible demo

https://docusaurus.io/docs/styling-layout

### Steps to reproduce

1. Go to https://docusaurus.io/docs/styling-layout
2. Set viewport width to ~1000px, just before the `@media` rule triggers
3. Set large font size in the browser
4. Observe the broken layout

### Expected behavior

IMHO it would make sense to use `rem` unit for `@media` thresholds as it would represent the "actual" scale of the content (accounting for both zoom and browser font size).

### Actual behavior

TOC on the right was unreasonably squished and navbar at the top has overlapping text. Normally with the content being enlarged this much a `@media` rule would trigger, but it does not happen because the threshold is tied to `px` and is not aware of browser font size setting.

![image_2023-10-10_18-07-29 (2)](https://github.com/facebook/docusaurus/assets/36504423/6d85cb60-bcba-4389-bb9e-e40695304f29)

### Your environment

Link: https://docusaurus.io/docs/styling-layout
Browser: Brave 1.58.137
OS: Windows 11

Also tried locally with `npx create-docusaurus@latest my-website classic` (pulled version 2.4.3), same result.

### Self-service

- [ ] I'd be willing to fix this bug myself.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。