Skip to content

How to expand focused search result when assigning text in the search textbox using code? #223

@SomoKRoceS

Description

@SomoKRoceS

Hello again :)

I am trying to force-search a term in the tree by code.
In other words, I want some text to be assigned to the search textbox (as a value, not a placeholder) in the moment the tree is loading up for the first time. I also want that the search will work with the focus, highlighting and expending.
The code I am using for the search method is the code presented in Storybook:
https://fritz-c.github.io/react-sortable-tree/storybook/?selectedKind=Basics&selectedStory=Search&full=0&down=1&left=1&panelRight=0&downPanel=storybook%2Fnotes%2Fpanel

So in the initial state I assigned to searchString a value passed to props instead of empty string ('').
searchFocusIndex is still 0. and searchFoundCount is null.

Well.. the value is assigned and appears in the search textbox, and the highlighting border of the selected matching node appears as well. But the tree wan't expending to that node.

I need that expansion so that the matching node will not be hidden by father (like triggering onChange on normal searching).

My only changes in the code:

this.state = {
      searchString: (this.props.x) ? this.props.x : '',
      searchFocusIndex: 0,
      searchFoundCount: null,
.
.
.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions