Skip to content

Commit

Permalink
FIX remove placeholder search text on readonly field
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewandante committed Oct 10, 2024
1 parent 483e944 commit 30049dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Forms/SearchableDropdownTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ public function getPlaceholder(): string
return $emptyString;
}
}
$name = $this->getName();
if ($this->getUseDynamicPlaceholder()) {
if ($this->getIsSearchable()) {
if (!$this->getIsLazyLoaded()) {
Expand Down Expand Up @@ -598,6 +597,9 @@ public function performReadonlyTransformation()
$field->setSource($this->sourceList);
$field->setReadonly(true);

// Remove the text "Type to search..." on a read-only field
$field->setUseDynamicPlaceholder(false);

return $field;
}
}
2 changes: 2 additions & 0 deletions tests/php/Forms/SearchableDropdownTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public function testPlaceholder(): void
$this->assertSame('My empty string', $field->getPlaceholder());
$field->setPlaceholder('My placeholder');
$this->assertSame('My placeholder', $field->getPlaceholder());
$readonlyField = $field->performReadonlyTransformation();
$this->assertSame('', $readonlyField->getPlaceholder());
}

public function testSeachContext(): void
Expand Down

0 comments on commit 30049dd

Please sign in to comment.