question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Native html form support for `Select`

See original GitHub issue

Since Select doesn’t render a native select element, it doesn’t works with the native html form element.

Solution: Add a visually hidden select element inside Select.

Problem: Native select element only accept string value, this means we have to remove support for object value in Select and only accept string value.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
martinpengellyphillipscommented, Mar 30, 2022

Yeah, I think it depends on the philosophy of the library. In this case, where it follows a more composed building blocks approach, I think supporting objects in this way isn’t needed.

0reactions
jprochazkcommented, Jun 3, 2022

I wonder if it makes sense in the end to allow the “object as a value” in my API.

Unless I’m misunderstanding something, with this approach, the user must have a mapping of option.id -> option in order to retrieve option using the value received in onChange. If you add something like compareFn, then you could also directly return the object to the user in onChange:

<Select
  compare={(option) => option.id}
  onChange={(option) => console.log(option)}
>
  <SelectOption value={option}>
    {option.label}
  </SelectOption>
</Select>

But this is not a deal-breaker, and there is definitely benefit in keeping things simple.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Past, Present And Future Of Native HTML Form Controls
In this article, Stephanie dives into the past by going back to the beginning of HTML and tracing the evolution of form controls...
Read more >
<select>: The HTML Select element - HTML - MDN Web Docs
The <select> HTML element represents a control that provides a ... For further examples, see The native form widgets: Drop-down content.
Read more >
HTML select tag - W3Schools
The <select> element is most often used in a form, to collect user input. ... The <select> tag also supports the Global Attributes...
Read more >
Forms in HTML documents - W3C
Users generally "complete" a form by modifying its controls (entering text, selecting menu items, etc.), before submitting the form to an agent for...
Read more >
How to Create a Placeholder for an HTML5 <select> Box
Styling HTML form fields, mainly <select> fields with CSS has always been ... First, you need to create your select items with the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found