Link field with single option results in broken state? Bug?

Setup
When creating a link field and restricting it to only pages, like so:

  link:
    label: Link
    type: link
    options:
      - page

Issue
The field looks as expected, however, when you click where it says “Select…”, you don’t get the dropdown of pages:

Screenshot 2024-01-23 at 09.22.14

You have to click on “Page” and then select “Page” (the only option), from the dropdown, then the pages dropdown appears as expected:

Screenshot 2024-01-23 at 09.23.43

Theory
It seems that “Page” isn’t actually selected, but is showing that it is, as it’s the only option. But there is visually no difference between the two states, so you would naturally expect the pages dropdown to appear.

Possible Solution
It looks like the issue is that the default “empty” option for the field is “Url”, even if “Url” isn’t an available option. So the solution could be to make the first option the default selected one, if the field is empty.

Currently, if you have the available options set to page and then url (in that order), it still defaults to Url despite it being the 2nd option:

link:
  label: Link
  type: link
  options:
    - page
    - url

Screenshot 2024-01-23 at 09.33.26

Could you please create an issue on GitHub?

Sure! (I only posted it here as that’s what it says to do at Debugging | Kirby CMS)

Issue created:

1 Like