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

Clearing text #104

Open
georgejdli opened this issue Feb 10, 2021 · 2 comments
Open

Clearing text #104

georgejdli opened this issue Feb 10, 2021 · 2 comments

Comments

@georgejdli
Copy link

I would like to be able to clear the current text from the display similar to you can clear the text from a terminal window by entering the "clear" command.

I played around with extended the LazyLog component in my project and added a "clearText" method that calls this.setState

class LazyLogClear extends LazyLog {
  clearText() {
   this.setState({
      count: 0,
      lines: null,
      isSearching: false,
      searchKeywords: '',
      resultLines: [],
      filteredLines: null,
      resultLineUniqueIndexes: [],
      isFilteringLinesWithMatches: false,
      scrollToIndex: 0,
    });
  }
}

To use this new method I would bind a ref (with useRef) to the LazyLogClear and call it elsewhere in my app.
The only issue I've seen so far is that if I have a query in the SearchBar that query doesn't reset and when I clear the text from the display it ends up giving an inaccurate count of matched items (phantom resultLines from previously cleared text).

Are there any other state properties I'm missing or do I need to extend the SearchBar component as well so I can pass a prop to clear the search query?

Is there any interest in adding this feature directly to react-lazylog?

@DanielLeefu
Copy link

very good

@melloware
Copy link

@georgejdli I would be interested in a PR in my fork for this feature. I can help get the SearchBar cleared as well.

GitHub: https://github.com/melloware/react-logviewer

Demo Site: https://melloware.github.io/react-logviewer/

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

3 participants