-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Javascript stops working on the website when the user's browser local storage has invalid value. #6645
Description
Context
We discussed about this bug here and @kamilkrzyskow suggested me to make an issue.
Bug description
If your browser has an invalid values like palette index in cache, the website will fail to load the whole Javascript stuffs.
I made a minimal standalone repository described on Reproduction section, so please have a look.
Related links
- Some unknown javascript error on deployed pages only which I am going to figure out soon #6644 (reply in thread)
- https://squidfunk.github.io/mkdocs-material/setup/changing-the-colors/?h=palette#color-palette-toggle
- https://squidfunk.github.io/mkdocs-material/contributing/reporting-a-bug/?h=bug
Reproduction
- 3 palettes: 9.5.3-3_palettes.zip
- 2 palettes: 9.5.3-2_palettes.zip
I made a repository to reproduce the exactly same thing on this repository. The steps are simple and you can follow and make exactly same .zip files.
Steps to reproduce
The content in this section is copied from this repository's README.md with slight modification.
Bug reproducing repository for mkdocs-material
This repository is used to introduce users to reproduce mkdocs-material bug discussed here.
Steps to reproduce in local
- Clone this repository.
- Make a virtual environment (Python 3.11) for this repository.
- Run
pip install --upgrade --force-reinstall mkdocs-materialto installmkdocs-material. - Checkout to commit ff4d4cf.
- Run
mkdocs servein your terminal to turn on local server. - Access
127.0.0.1:8000from your browser. - Press button on the website to make palette to the dark mode.
- Checkout to commit a0d3b0b and refresh your build (
mkdocs servewill refresh automatically). - Enjoy the bug. Javascript stuffs like searching, side navigations wouldn't work.
Steps to reproduce .zip files
Since mkdocs-material encourages people to use .zip files made by info plugin instead of making a repository, I am going to make 2 .zip files.
- Run
echo 2_palettes | mkdocs build -f mkdocs_2_palettes.yml - Run
echo 3_palettes | mkdocs build -f mkdocs_3_palettes.yml
Proposal to resolve this
I suggest to insert a validation JS code for invalid values in cache.
Browser
Edge
Before submitting
- I have read and followed the bug reporting guidelines.
- I have attached links to the documentation, and possibly related issues and discussions.
- I assure that I have removed all customizations before submitting this bug report.
- I have attached a .zip file with a minimal reproduction.
