Description
The bug:
While having a liveform with required select and placeholder of type TranslatableMessage, instead of leaving this value blank, first not null value from choices is retrieved instead.
This behaviour occurs because of code in Symfony\UX\LiveComponent\ComponentWithFormTrait
in if on line 276.
In this if, the last condition is !\is_string($child->vars['placeholder'])
which unfortunately is not satisfied e.g. for option 'placeholder' => new TranslatableMessage('some.value')
.
Solution
I would suggest to extending this condition to (!\is_string($child->vars['placeholder']) && !$child->vars['placeholder'] instanceof TranslatableMessage)
or making it only !isset($child->vars['placeholder'])
to support more cases. I feel that string only restriction is to harsh when most of the time, we will be creating multilingual applications.
We use TranslatableMessage class for translatable strings so our extractor can generate .yaml files with translations.