-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autocomplete dropdown not re-appearing after making typo #977
Comments
After browsing previous issues, it could look like a regression of this: |
@rasmuscnielsen thanks for reporting! I've submitted a PR with a fix. PR description below. The scenarioIf you have an autocomplete component, normally when you start typing in the input, the options will be filtered until there are no options left. When that happens, the options dropdown is then hidden. If the user backspaces in the input, then the options dropdown should reappear if there is a match. But in Safari 18 (released end 2024) on iOS and macOS, the autocomplete component will no longer re-show the autocomplete options dropdown once there is a match again. <?php
use Livewire\Volt\Component;
new class extends Component {
public $state;
};
?>
<div>
<flux:autocomplete wire:model="state" label="State of residence">
<flux:autocomplete.item>Alabama</flux:autocomplete.item>
<flux:autocomplete.item>Arkansas</flux:autocomplete.item>
<flux:autocomplete.item>California</flux:autocomplete.item>
<!-- ... -->
</flux:autocomplete>
</div> The problemWhen I dug into this, I found that the way that the autocomplete shows/hides the options dropdown is through a calculation of how many options are visible or not. let isHidden = el => getComputedStyle(el).display === 'none'
...
empty = Array.from(list.querySelectorAll('& > ui-option')).filter(i => ! isHidden(i)).length === 0 In Chrome, if we have a hidden options dropdown and check the visibility of one of the options within it, it will return Where as it seems that in Safari 18, The solutionThe solution is to instead filter the options based on whether they have the let isHidden = el => el.hasAttribute('data-hidden')
...
empty = Array.from(list.querySelectorAll('& > ui-option')).filter(i => ! isHidden(i)).length === 0 Fixes #977 |
@joshhanley This is awesome - thank you so much for a fix + detailed description! |
Flux version
v1.1.2
Livewire version
v3.5.18
What is the problem?
In safari (web + mobile) the autocomplete doesn't reappear after having made a typo. Even when dismissed and refocused it doesn't reappear - it requires a full page reload.
Sidenote: There is also a bit of glitching with focus automatically being hijacked when clicked outside, although this is not as significant as the other bug.
See videos with reproduction on the fluxui.dev website:
macOS 15.0 Safari 18: https://share.icloud.com/photos/0c4FPmK9GZ_4BJYTO9vCP78NA
iOS 18.1.1: https://share.icloud.com/photos/0dfTAnOIo4Y9PQwdp0qyjJhEw
chrome 131: works fine
Code snippets
Tested straight on docs website.
How do you expect it to work?
Chrome works well already, with the exception that when clicked outside I would expect it to loose focus, not automatically regain it.
Please confirm (incomplete submissions will not be addressed)
The text was updated successfully, but these errors were encountered: