Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Event binding of body.ready on mobile devices causes abnormal switching of the sidebar

Aperta
#1,697 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript
Ambito
frontend

Direzione di ricerca

Inizia con il CodeSandbox riproducibile e la funzione btn intorno alle righe 1932–1938. Riproduci il comportamento su un dispositivo mobile usando button.sidebar-toggle, quindi esamina il binding del click su body e verifica che i click sulla sidebar non attivino più un toggle involontario, mentre il pulsante continui a funzionare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

needs investigation

Bug Report

On mobile devices, docsify will add a click event to the body element.
When the event is not removed, clicking any area in the left sidebar will trigger its switching function.
After removing the event, the function is normal.

Its position is between 1932 -> 1938:

   function btn(el) {
     var toggle = function (_) {return body.classList.toggle('close'); };

     el = getNode(el);
     if (el === null || el === undefined) {
       return;
     }

     on(el,'click', function (e) {
       e.stopPropagation();
       toggle();
     });
     // this position
     isMobile &&
       on(
         body,
         'click',
         function (_) {return body.classList.contains('close') && toggle();}
       );
   }

Just like in the picture, this is when I did not remove the event:

bug1

When I removed the event, everything returned to normal:

bug2

I don't understand the meaning of this event, because after I disable it, I feel that everything is normal.

Steps to reproduce

On mobile devices, click button.sidebar-toggle. Click again on any area in the sidebar.

What is current behaviour

It will automatically close the sidebar.

What is the expected behaviour

Only when the button.sidebar-toggle button is clicked, can the sidebar toggle function be triggered.

Other relevant information
  • Bug does still occur when all/other plugins are disabled?

  • Your OS: ubuntu 20.04.3 LTS

  • Node.js version: 10.24.1

  • npm/yarn version: 6.4.12

  • Browser version: any browser

  • Docsify version: 4.4.3

  • Docsify plugins:

gitalk
search
emoji
docsify-copy-code
countable
pangu
sidebar
progress
gifcontrol
pagination
Please create a reproducible sandbox

Edit 307qqv236

Mention the docsify version in which this bug was not present (if any)
Lingua principale
JavaScript
Stelle
31.5k
Fork
5.8k
Merge medio
2g 14h
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di docsifyjs/docsify

Tutte le issue di docsifyjs/docsify

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.