laravel / prompts

Beautiful and user-friendly forms for your command-line PHP applications.

Home Page:https://laravel.com/docs/prompts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any luck with more natural scroll list?

crazywhalecc opened this issue · comments

I yesterday tried to contribute to the project to support a natural scroll method, and I realized there is no view state variable. For detail:

  1. My expectation: Only when I scroll to an item outside of the displayed one, do I scroll to the displayed item on the page.
  2. Actual: When I scroll the list (select, multiselect, search), and options count is bigger than height, the highlighted option is always last one of view, related code:
    return $lines->slice($focused - $height + 1, $height);
  3. And I tried to add a variable to render, I realize renderer creates every input time. So I also added a static instance variable to persist this object, but another bug appeared: it will top up the previous window.
  4. As far as I know, the Prompt class is the only one that can be used as storing view state.

I would be happy if you could provide some ideas or if this issue could be resolved appropriately. I don't know if this is more reasonable.

This is something I had hoped to achieve, but I was already finding it quite challenging to position the scrollbar just based on the number of items and the currently selected item, ensuring that the scrollbar is never in the first or last position until you reach the first or last item. The added state required to do what you're talking about, and all the possible scenarios it introduces, was a little overwhelming, and I didn't mind the feel of what I landed on.

The same is true with the horizontal scrolling in text-based inputs.

I'm definitely open to suggestions or PRs, but I have a few other things on so I probably won't be able to look at this myself for a little while.

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

Closing this to continue the discussion at #43