Skip to content

Commit 55b45c4

Browse files
committed
updated readme, and better selection behavior
1 parent c0432ad commit 55b45c4

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $result = explorer(
2222
[2, 'Jane Doe', 'jane.doe@example.com'],
2323
[3, 'Jan Kowalski', 'kowalski@example.com'],
2424
],
25-
title: 'Hello from a explorer window'
25+
title: 'Hello from a explorer window',
2626
header: [
2727
'ID',
2828
'Name',

src/Concerns/TypedValue.php

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ protected function handleFilterKey(string $key)
4646

4747
// Keys may be buffered.
4848
foreach (mb_str_split($key) as $key) {
49+
$this->setSelection(0);
50+
4951
if ($key === Key::ENTER) {
5052
$this->setActiveState();
5153
} elseif ($key === Key::BACKSPACE || $key === Key::CTRL_H) {

src/Themes/Default/ExplorerPromptRenderer.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ class ExplorerPromptRenderer extends Renderer
1818
public function __invoke(ExplorerPrompt $prompt): string
1919
{
2020
if ($this->prompt->state !== 'submit') {
21-
$filteredCount = count($this->prompt->filteredItems());
22-
if ($filteredCount < $this->prompt->highlighted) {
23-
$this->prompt->setSelection(0);
24-
}
25-
2621
$visibleItems = collect($this->prompt->visible())
2722
->values()
2823
->map(function ($row) {
@@ -43,7 +38,7 @@ public function __invoke(ExplorerPrompt $prompt): string
4338
$visibleItems,
4439
$this->prompt->firstVisible,
4540
$this->prompt->scroll,
46-
$filteredCount,
41+
count($this->prompt->filteredItems()),
4742
$this->prompt->terminal()->cols() - 6
4843
)
4944
->map(function ($label, $key) {

0 commit comments

Comments
 (0)