Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
react-dropdown-input
Advanced tools
Displays a Bootstrap Input element with a DropdownMenu of possible options (similar to a combobox)
React-dropdown-input displays a "combobox" for React. More explicitly, it shows a text input box; once the user starts to type, a dropdown menu opens with matching options. The user can choose one of those options either by clicking one, or by using the arrow keys and hitting Enter.
It is styled with bootstrap, using the React-Bootstrap package; it actually displays a ReactBootstrap.Input
element
with a ReactBootstrap.DropdownMenu
of possible options.
http://racingtadpole.github.io/react-dropdown-input/example/
npm install react-dropdown-input --save
var searchNames = ['Sydney', 'Melbourne', 'Brisbane',
'Adelaide', 'Perth', 'Hobart'];
//...
<DropdownInput
options={searchNames}
defaultValue={this.props.initialValue}
menuClassName='dropdown-input'
onSelect={this.handleSelectName}
placeholder='Search...'
/>
The options are simply passed as a javascript array (or immutablejs object)
to the options
prop.
Supply one or both of these callbacks: onSelect
& onChange
.
onSelect
fires when an option is clicked, or when Enter is pressed.
It passes the object:
{ value: input text,
index: option index, or -1 if user entered their own text and pressed Enter
}
onChange
fires whenever the input text value changes, either due to a click or typing.
It passes the object:
{ value: input text }
Other props you can pass:
filter
: a function that determines which options to show, given the input text
(see defaultFilter
in the code for the default).menuClassName
: a class for the menu, which you need for the css styling below;
eg. 'dropdown-input'.max
: the maximum number of options to display.maxText
: text of a disabled MenuItem to show at the end of a list, if the max is exceeded
replaces '#' with the number not shown; defaults to '+# more not shown'.You can also pass <DropdownInput>
all the properties that <ReactBootstrap.Input>
allows,
eg. ButtonAfter
.
You need to turn off Bootstrap's hover highlighting css for this element; we do it manually using the active class instead. You may also need to re-enable the hover highlighting on the active class. Eg. in sass, add this:
.dropdown-input.dropdown-menu > li > a {
&:hover,
&:focus {
color: $dropdown-link-color; // #333
background-color: $dropdown-bg; // #fff
}
}
.dropdown-input.dropdown-menu > .active > a {
&:hover,
&:focus {
text-decoration: none;
color: $dropdown-link-hover-color; // #fff
background-color: $dropdown-link-hover-bg; // #337ab7
}
}
If you're showing maxText
, you may also want to make sure it can't be selected too:
.dropdown-input.dropdown-menu>.active.disabled>a {
text-decoration: none;
color: $dropdown-link-disabled-color; // #777
background-color: $dropdown-bg; // #fff
}
FAQs
Displays a Bootstrap Input element with a DropdownMenu of possible options (similar to a combobox)
The npm package react-dropdown-input receives a total of 855 weekly downloads. As such, react-dropdown-input popularity was classified as not popular.
We found that react-dropdown-input demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.