Well the datalist shows when clicked on in Chrome as well. What exact behavior are you trying to create? (I’m not 100% sure you can, because a datalist’s presentation is a browser element, not a page one, but…)
If you click on the input box the input box the list appears, but you click on the input box again the list disappears in firefox which is what I want - in chrome the list disappears on blur.
The code provided by chatGPT… would work… feels like a bit of a club, but it would work. It could be simplified to remove the firstTime flag by removing the list attribute from the HTML, and relying on the Javascript to put it back, but that would make the behavior in a non-JS environment poorer.
So the requirement is the default behaviour in FireFox, had to do this instead of implementing something like select2 which is jQuery dependent. We want to have 0 dependency on jQuery. Even ES2022 would do.
As i said, the script you’ve got now will work in any browser with standard vanilla javascript, because it just disassociates the datalist from the text input. The browser would then revert to displaying the element like any other input element, until the list is reattached.