Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More examples, including using meta #47

Open
baloodevil opened this issue May 22, 2024 · 0 comments
Open

More examples, including using meta #47

baloodevil opened this issue May 22, 2024 · 0 comments

Comments

@baloodevil
Copy link

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant