-
Notifications
You must be signed in to change notification settings - Fork 12
Description
@marchaos Appreciate your support. This is a well written library that allows consumers to bring their own data structure.
With a POC running, I would like more functionality in my app.
- Row Selection - selecting happens when a user clicks a row it changes style to show it is selected. One row at a time can be selected.
- Row Highlighting - a highlighted row has a border around it. When a user presses up or down arrows, the highlight moves up or down a row. One row at a time can be highlighted. Pressing Enter selects the highlighted row.
What is an efficient way to implement this? My default is state variables for selectedNode and highlightedNode and when rendering each row, check if the currently rendered id is the id of the selectedNode or highlightedNode and style accordingly. Another approach is to have a selected and highlighted boolean on each node. But the rules may change with a library like this that manages its own state and refresh.
I saw the generic property meta in source code which does not cause a tree rebuild but re-rendering visible nodes. Would that be the right way to manage this piece state and refresh logic? If so, could you add to the examples folder? I see how to access meta from rowRenderer. But how to update specific node's meta values?
For highlighting on down arrow, should getNextNodeId be used? Or maybe use the node index and code like setHighlightedNode(countries[highlightedNode.index+1]). What is an efficient approach that avoids a full tree scan every time a user clicks the down arrow?