In jest environment: Expand by clicking switcher stays in motion and does not work

Aperta
#544 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
react, typescript

Direzione di ricerca

Inizia riproducendo il test helper che fa clic su uno switcher di Tree e verifica la presenza dell’elemento ant-tree-treenode-motion. Leggi il gestore di espansione di Tree intorno alla guardia listChanging e analizza il comportamento di useStepQueue di rc-motion, in particolare la pulizia di requestAnimationFrame. Il lavoro è completato quando l’espansione termina nel test e una successiva espansione del nodo viene accettata.

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

Descrizione

I have a helper function that expands a tree node (node1) by clicking on the switcher element.

  • The onExpand handler is invoked with expanded = true.
  • But I noticed that the tree is still animation mode. Reasons it is still in animation mode:
    • The child nodes of the expanded node1 are still inside a div element <div class="ant-tree-treenode-motion">{my 3 child treeNodes are here}</div>

    • In the same test, I try to expand another node (node2) but it does not expand. I debugged and learned that the Tree component rejects node2 expand (Tree's expand handler is correctly invoked) because of the below code ...

      var key = treeNode.key,
      expanded = treeNode.expanded; // Do nothing when motion is in progress
      
      if (listChanging) {
          return;
      }
      
    • I also debugged further and went into the rc-motion code. The hook useStepQueue's below code is invoked and the requestAnimationFrame is canceled (I am not sure if this is normal or not). But the step never moved forward from "NONE"

      React.useEffect(function () {
          return function () {
              cancelNextFrame();
         };
      }, []);
  • I studied the test code in this repo. The test clicks on a switcher and makes sure the handler is invoked. It does not test if the tree is in animation mode or not. I have written this code to make sure the Tree is not animating:
    isAnimating: (tree: HTMLElement) => {
          return !!tree.querySelector('.ant-tree-treenode-motion');
    },

We use the Tree component a lot in our UI and we need to test our features. Appreciate if you guys can help.

Lingua principale
TypeScript
Stelle
1.3k
Fork
494
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 react-component/tree

Tutte le issue di react-component/tree

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.