Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion resources/dist/components/combobox.js

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions resources/js/components/combobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -1347,11 +1347,15 @@ class Combobox {

if (!this.isMultiple) {
this.state = value
this.searchQuery = ''
if (this.searchInput) {
this.searchInput.value = ''

if (blank(value)) {
this.searchQuery = ''
if (this.searchInput) {
this.searchInput.value = ''
}
this.options = JSON.parse(JSON.stringify(this.originalOptions))
}
this.options = JSON.parse(JSON.stringify(this.originalOptions))

this.updateSelectedDisplay()
this.renderOptions()
this.onStateChange(this.state)
Expand Down
19 changes: 18 additions & 1 deletion tests/Browser/ComboboxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ function comboboxClearButton(string $field): string
->wait(3)
->assertSeeIn(comboboxOptions('category_id'), 'Technology')
->click(comboboxOption('category_id', '1'))
->assertAttribute(comboboxInput('category_id'), 'placeholder', 'Technology');
->assertValue(comboboxInput('category_id'), 'Tech')
->assertAttribute(comboboxOption('category_id', '1'), 'aria-selected', 'true')
->assertSeeIn(comboboxOptions('category_id'), 'Technology');
});

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -218,6 +220,21 @@ function comboboxClearButton(string $field): string
->assertMissing(comboboxOption('status', 'archived'));
});

it('preserves the search query and filtered options after selecting a static result', function () {
$page = visit('/admin/posts/create');

$page->click(comboboxInput('status'))
->typeSlowly(comboboxInput('status'), 'pub')
->assertVisible(comboboxOption('status', 'published'))
->click(comboboxOption('status', 'published'))
->assertValue(comboboxInput('status'), 'pub')
->assertAttribute(comboboxOption('status', 'published'), 'aria-selected', 'true')
->assertVisible(comboboxOption('status', 'published'))
->assertMissing(comboboxOption('status', 'draft'))
->assertMissing(comboboxOption('status', 'review'))
->assertMissing(comboboxOption('status', 'archived'));
});

// ---------------------------------------------------------------------------
// Clear button removes selection
// ---------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion tests/BrowserTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Prvious\Filament\Combobox\ComboboxServiceProvider;
use RyanChandler\BladeCaptureDirective\BladeCaptureDirectiveServiceProvider;
use Workbench\App\Providers\WorkbenchServiceProvider;
use Workbench\Database\Seeders\DatabaseSeeder;

class BrowserTestCase extends Orchestra
{
Expand Down Expand Up @@ -71,6 +72,6 @@ protected function defineDatabaseMigrations(): void

protected function defineDatabaseSeeders(): void
{
$this->seed(\Workbench\Database\Seeders\DatabaseSeeder::class);
$this->seed(DatabaseSeeder::class);
}
}
3 changes: 2 additions & 1 deletion workbench/app/Providers/WorkbenchServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
namespace Workbench\App\Providers;

use Illuminate\Support\ServiceProvider;
use Workbench\App\Providers\Filament\AdminPanelProvider;

class WorkbenchServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->app->register(\Workbench\App\Providers\Filament\AdminPanelProvider::class);
$this->app->register(AdminPanelProvider::class);
}

public function boot(): void
Expand Down
2 changes: 1 addition & 1 deletion workbench/database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Workbench\App\Models\User;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\Workbench\App\Models\User>
* @extends Factory<User>
*/
class UserFactory extends Factory
{
Expand Down
Loading