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

Offen
#544 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Muss geklärt werden
Aktivitätsstatus
Veraltet
Tech-Stack
react, typescript
Bereich
frontend, testing-qa

Rechercherichtung

Beginne damit, den Helper-Test zu reproduzieren, der auf einen Tree-Switcher klickt und das Element ant-tree-treenode-motion prüft. Lies den Tree-Expand-Handler rund um den listChanging-Guard und untersuche das Verhalten von rc-motions useStepQueue, insbesondere die Bereinigung von requestAnimationFrame. Fertig ist es, wenn die Expansion im Test abgeschlossen wird und eine anschließende Node-Expansion akzeptiert wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
TypeScript
Sterne
1.3k
Forks
494
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus react-component/tree

Alle Issues in react-component/tree

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.