FIX Allow clearing lazyloaded SearchableDropdownField. (#11324)

This commit is contained in:
Guy Sartorelli 2024-08-06 15:35:36 +12:00 committed by GitHub
parent a8d0d1ef58
commit 9fae48bbd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 5 deletions

View File

@ -29,7 +29,7 @@ trait SearchableDropdownTrait
'search',
];
private bool $isClearable = false;
private bool $isClearable = true;
private bool $isLazyLoaded = false;

View File

@ -24,6 +24,5 @@ class SearchableMultiDropdownField extends MultiSelectField
$this->setLabelField($labelField);
$this->addExtraClass('ss-searchable-dropdown-field');
$this->setIsMultiple(true);
$this->setIsClearable(true);
}
}

View File

@ -205,16 +205,16 @@ class SearchableDropdownTraitTest extends SapphireTest
$field->setForm($form);
$schema = $field->getSchemaDataDefaults();
$this->assertFalse($schema['lazyLoad']);
$this->assertFalse($schema['clearable']);
$this->assertTrue($schema['clearable']);
$this->assertSame('Select or type to search...', $schema['placeholder']);
$this->assertTrue($schema['searchable']);
$field->setIsLazyLoaded(true);
$field->setIsClearable(true);
$field->setIsClearable(false);
$field->setPlaceholder('My placeholder');
$field->setIsSearchable(false);
$schema = $field->getSchemaDataDefaults();
$this->assertTrue($schema['lazyLoad']);
$this->assertTrue($schema['clearable']);
$this->assertFalse($schema['clearable']);
$this->assertSame('My placeholder', $schema['placeholder']);
$this->assertFalse($schema['searchable']);
}