Skip to content

Commit

Permalink
Choices: add support for placeholders (#645)
Browse files Browse the repository at this point in the history
* Choices: add support for placeholders

* WIP

---------

Co-authored-by: Robson Tenório <rrtenorio@gmail.com>
  • Loading branch information
anfeichtinger and robsontenorio authored Sep 28, 2024
1 parent 169c7ff commit bad16e3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/View/Components/Choices.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function render(): View|Closure|string
isDisabled: {{ json_encode($isDisabled()) }},
isRequired: {{ json_encode($isRequired()) }},
minChars: {{ $minChars }},
init() {
// Fix weird issue when navigating back
document.addEventListener('livewire:navigating', () => {
Expand Down Expand Up @@ -283,6 +283,13 @@ class="outline-none mt-0.5 bg-transparent w-20"
@keydown.debounce.{{ $debounce }}="search($el.value)"
@endif
/>
<!-- PLACEHOLDER -->
@if (!$compact && $attributes->has('placeholder'))
<span @class(["absolute inset-0 mt-2.5 me-8 truncate text-base text-gray-400 pointer-events-none", $icon ? "ms-10" : "ms-4"]) x-show="isSelectionEmpty && !focused">
{{ $attributes->get('placeholder') }}
</span>
@endif
</div>
<!-- APPEND -->
Expand Down
7 changes: 7 additions & 0 deletions src/View/Components/ChoicesOffline.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,13 @@ public function render(): View|Closure|string
:class="(isReadonly || isDisabled || !isSearchable || !focused) && '!w-1'"
class="outline-none mt-0.5 bg-transparent w-20"
/>
<!-- PLACEHOLDER -->
@if (!$compact && $attributes->has('placeholder'))
<span @class(["absolute inset-0 mt-2.5 me-8 truncate text-base text-gray-400 pointer-events-none", $icon ? "ms-10" : "ms-4"]) x-show="!focused && isSelectionEmpty">
{{ $attributes->get('placeholder') }}
</span>
@endif
</div>
Expand Down

0 comments on commit bad16e3

Please sign in to comment.