Giter Club home page Giter Club logo

react-autocomplete's Introduction

React Autocomplete Travis build status

Accessible, extensible, Autocomplete for React.js.

<Autocomplete
  getItemValue={(item) => item.label}
  items={[
    { label: 'apple' },
    { label: 'banana' },
    { label: 'pear' }
  ]}
  renderItem={(item, isHighlighted) =>
    <div style={{ background: isHighlighted ? 'lightgray' : 'white' }}>
      {item.label}
    </div>
  }
  value={value}
  onChange={(e) => value = e.target.value}
  onSelect={(val) => value = val}
/>

Check out more examples and get stuck right in with the online editor.

Install

npm

npm install --save react-autocomplete

yarn

yarn add react-autocomplete

AMD/UMD

API

Props

getItemValue: Function

Arguments: item: Any

Used to read the display value from each entry in items.

items: Array

The items to display in the dropdown menu

renderItem: Function

Arguments: item: Any, isHighlighted: Boolean, styles: Object

Invoked for each entry in items that also passes shouldItemRender to generate the render tree for each item in the dropdown menu. styles is an optional set of styles that can be applied to improve the look/feel of the items in the dropdown menu.

autoHighlight: Boolean (optional)

Default value: true

Whether or not to automatically highlight the top match in the dropdown menu.

inputProps: Object (optional)

Default value: {}

Props passed to props.renderInput. By default these props will be applied to the <input /> element rendered by Autocomplete, unless you have specified a custom value for props.renderInput. Any properties supported by HTMLInputElement can be specified, apart from the following which are set by Autocomplete: value, autoComplete, role, aria-autocomplete. inputProps is commonly used for (but not limited to) placeholder, event handlers (onFocus, onBlur, etc.), autoFocus, etc..

isItemSelectable: Function (optional)

Default value: function() { return true }

Arguments: item: Any

Invoked when attempting to select an item. The return value is used to determine whether the item should be selectable or not. By default all items are selectable.

menuStyle: Object (optional)

Default value:

{
  borderRadius: '3px',
  boxShadow: '0 2px 12px rgba(0, 0, 0, 0.1)',
  background: 'rgba(255, 255, 255, 0.9)',
  padding: '2px 0',
  fontSize: '90%',
  position: 'fixed',
  overflow: 'auto',
  maxHeight: '50%', // TODO: don't cheat, let it flow to the bottom
}

Styles that are applied to the dropdown menu in the default renderMenu implementation. If you override renderMenu and you want to use menuStyle you must manually apply them (this.props.menuStyle).

onChange: Function (optional)

Default value: function() {}

Arguments: event: Event, value: String

Invoked every time the user changes the input's value.

onMenuVisibilityChange: Function (optional)

Default value: function() {}

Arguments: isOpen: Boolean

Invoked every time the dropdown menu's visibility changes (i.e. every time it is displayed/hidden).

onSelect: Function (optional)

Default value: function() {}

Arguments: value: String, item: Any

Invoked when the user selects an item from the dropdown menu.

open: Boolean (optional)

Used to override the internal logic which displays/hides the dropdown menu. This is useful if you want to force a certain state based on your UX/business logic. Use it together with onMenuVisibilityChange for fine-grained control over the dropdown menu dynamics.

renderInput: Function (optional)

Default value:

function(props) {
  return <input {...props} />
}

Arguments: props: Object

Invoked to generate the input element. The props argument is the result of merging props.inputProps with a selection of props that are required both for functionality and accessibility. At the very least you need to apply props.ref and all props.on<event> event handlers. Failing to do this will cause Autocomplete to behave unexpectedly.

renderMenu: Function (optional)

Default value:

function(items, value, style) {
  return <div style={{ ...style, ...this.menuStyle }} children={items}/>
}

Arguments: items: Array<Any>, value: String, styles: Object

Invoked to generate the render tree for the dropdown menu. Ensure the returned tree includes every entry in items or else the highlight order and keyboard navigation logic will break. styles will contain { top, left, minWidth } which are the coordinates of the top-left corner and the width of the dropdown menu.

selectOnBlur: Boolean (optional)

Default value: false

Whether or not to automatically select the highlighted item when the <input> loses focus.

shouldItemRender: Function (optional)

Arguments: item: Any, value: String

Invoked for each entry in items and its return value is used to determine whether or not it should be displayed in the dropdown menu. By default all items are always rendered.

sortItems: Function (optional)

Arguments: itemA: Any, itemB: Any, value: String

The function which is used to sort items before display.

value: Any (optional)

Default value: ''

The value to display in the input field

wrapperProps: Object (optional)

Default value: {}

Props that are applied to the element which wraps the <input /> and dropdown menu elements rendered by Autocomplete.

wrapperStyle: Object (optional)

Default value:

{
  display: 'inline-block'
}

This is a shorthand for wrapperProps={{ style: <your styles> }}. Note that wrapperStyle is applied before wrapperProps, so the latter will win if it contains a style entry.

Imperative API

In addition to the props there is an API available on the mounted element which is similar to that of HTMLInputElement. In other words: you can access most of the common <input> methods directly on an Autocomplete instance. An example:

class MyComponent extends Component {
  componentDidMount() {
    // Focus the input and select "world"
    this.input.focus()
    this.input.setSelectionRange(6, 11)
  }
  render() {
    return (
      <Autocomplete
        ref={el => this.input = el}
        value="hello world"
        ...
      />
    )
  }
}

Development

You can start a local development environment with npm start. This command starts a static file server on localhost:8080 which serves the examples in examples/. Hot-reload mechanisms are in place which means you don't have to refresh the page or restart the build for changes to take effect.

Tests!

Run them: npm test

Write them: lib/__tests__/Autocomplete-test.js

Check your work: npm run coverage

Scripts

Run with npm run <script>.

gh-pages

Builds the examples and assembles a commit which is pushed to origin/gh-pages, then cleans up your working directory. Note: This script will git checkout master before building.

release

Takes the same argument as npm publish, i.e. [major|minor|patch|x.x.x], then tags a new version, publishes, and pushes the version commit and tag to origin/master. Usage: npm run release -- [major|minor|patch|x.x.x]. Remember to update the CHANGELOG before releasing!

build

Runs the build scripts detailed below.

build:component

Transpiles the source in lib/ and outputs it to build/, as well as creating a UMD bundle in dist/.

build:examples

Creates bundles for each of the examples, which is used for pushing to origin/gh-pages.

test

Runs the test scripts detailed below.

test:lint

Runs eslint on the source.

test:jest

Runs the unit tests with jest.

coverage

Runs the unit tests and creates a code coverage report.

start

Builds all the examples and starts a static file server on localhost:8080. Any changes made to lib/Autocomplete.js and the examples are automatically compiled and transmitted to the browser, i.e. there's no need to refresh the page or restart the build during development. This script is the perfect companion when making changes to this repo, since you can use the examples as a test-bed for development.

react-autocomplete's People

Contributors

bell-steven avatar bfink13 avatar bgelineau avatar christianvuerings avatar cmtegner avatar daniel15 avatar garrettmaring avatar golmansax avatar hontas avatar kyleamathews avatar longtian avatar mattraykowski avatar neitsch avatar pwmckenna avatar rxaviers avatar ryanflorence avatar ssteffey avatar teameh avatar whichsteveyp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-autocomplete's Issues

Element to clear control

We use initialvalue (now it is value) to render saved result.

Can u add any element to clear the search string?

Cannot read property ownerDocument of null

Inside the custom menu demo, I got this error http://rackt.github.io/react-autocomplete/custom-menu/

Uncaught TypeError: Cannot read property 'ownerDocument' of nullgetClientPosition @ shared.js:20971
getOffset @ shared.js:21034
module.exports.offset @ shared.js:21336
scrollIntoView @ shared.js:20856
maybeScrollItemIntoView @ shared.js:20561
componentDidUpdate @ shared.js:20554
assign.notifyAll @ shared.js:3435O
N_DOM_READY_QUEUEING.close @ shared.js:17673
Mixin.closeAll @ shared.js:4738
Mixin.perform @ shared.js:4679
Mixin.perform @ shared.js:4665
assign.perform @ shared.js:3177
flushBatchedUpdates @ shared.js:3257
ReactPerf.measure.wrapper @ shared.js:3540
NESTED_UPDATES.close @ shared.js:3133
Mixin.closeAll @ shared.js:4738
Mixin.perform @ shared.js:4679
assign.perform @ shared.js:3177
flushBatchedUpdates @ shared.js:3257
ReactPerf.measure.wrapper @ shared.js:3540
Mixin.closeAll @ shared.js:4738
Mixin.perform @ shared.js:4679
ReactDefaultBatchingStrategy.batchedUpdates @ shared.js:15795
batchedUpdates @ shared.js:3192
ReactEventListener.dispatchEvent @ shared.js:17396

Web Pack Error "Unexpected token <"

Hi, I've been having a difficult time getting this to build in webpack.

I installed with NPM
I am using the Grunt Webpack plugin with the JSX loader . I have set the loader like this, with the thought that it would match both .js and .jsx files:

      { test: /\.js.*$/, loader: 'jsx-loader' },

the problem is I keep getting the error.

Any thoughts on how to make Webpack build this? or what I'm doing wrong.

React 0.14: Invariant Violation: addComponentAsRefTo(...) Error

I get this fine error when I use the autocomplete widget with 0.14:

Uncaught Error: Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component'srendermethod, or you have multiple copies of React loaded (details: https://fb.me/react-refs-must-have-owner).

It can probably be fixed by removing the refs and doing some other trickiness instead.

Add relay support

It would be awesome if you added support for pulling data in from a graphql query via relay. Do you have any plans to?

Consider an API to clear the textbox

I can't figure out a way to set the state to empty without manually deleting the characters. Probably I'm doing something crazy, but it might be nice if we could programmatically clear (or just set the value). Not sure the best way to do it.

onSelect event is triggered erroneously

If you set the combobox to autocomplete and you type the beggining of something in your list and it has the rest of the element highlighted (autocompleted) and click anywhere else (other than any part of the combobox or combooption elements) the on select event will fire even though it shouldn't.

Here's the relevant part of my code (my combobox only uses an array, not an array of Ids and Names):

var VariableSearch = React.createClass({
    getInitialState: function() {
        return {
            //list of possible values
            matches: this.props.list,
            // the current selection
            selected: ''
        };
    },

    // called by the combobox when the user types into the field the point is to
    // set some state to cause a redraw of the options
    handleInput: function(userInput) {
        // make sure to clear out the current selection
        this.setState({selected: null}, function() {
            // and then do our client-side filtering, need to it after setState has happened
            // so that the value doesn't get rerendered to the old selected
            // (this might be bad implementation at this point, still exploring a better
            // way to handle this)
            this.filterStates(userInput);
        }.bind(this));
    },

    // this demo uses client-side filtering, but you can easily query a server
    // instead and then set state when the response lands
    filterStates: function(userInput) {
        if (userInput === '' || userInput == null) {
            return this.setState({matches: this.props.list});
        }
        else {
            var filter = new RegExp('^'+userInput, 'i');
            //setTimeout(function() {
            //  this.setState({matches: this.props.list.filter(function(name) {
            //      return filter.test(name);
            //  })});
            //}.bind(this), 500);
            return this.setState({matches: this.props.list.filter(function(name) {
                        return filter.test(name);
            })});
        }
    },

    // Called by the Combobox when the user makes a selection
    handleSelect: function(value) {
        this.props.handleVariableClick(value);
        this.setState({
            selected: value,
            // for client-side filtering you probably want to populate your list
            // again so when they open it they can choose something besides what they
            // just picked
            matches: this.props.list
        });
    },

    renderComboboxOptions: function() {
        // render calls this, it creates all the options for the combobox
        return this.state.matches.map(function(name) {
            return (
                    <ComboboxOption key={name} value={name}>{name}</ComboboxOption>
            );
        },this);
    },

    render: function() {
        var menuContent = this.state.matches.length ?
            this.renderComboboxOptions() :
            // if none of the options match what the user has typed, tell them
            <div style={{padding: '8px'}} aria-live="polite">No matches</div>;
        return (
                <div>
                <Combobox onInput={this.handleInput} onSelect={this.handleSelect} value={this.state.selected} autocomplete="both">
                {menuContent}
            </Combobox>
                </div>
        );
    }
});


var testlist = [
"rgfint",
"rgw",
"rme",
"rpd",
"rrffe",
"rrfix",
"rrmet",
"rrtr",
"rspnia",
"rstar",
"rtb",
"rtbe",
"rtinv",
"rtpd",
"rtpi",
"rtps",
"rtr",
"t47",
"tapdad",
"tapdd",
"tapddp",
"tapds",
"tapdt",
"tapsad",
"tapsda",
"tapssl",
"tfcin",
"tfibn",
"tfpn",
"tfsin",
"trfci",
"trfcim",
"trfib",
"trfp",
"trfpm",
"trfpt",
"trfptx",
"trfsi",
"trsci",
"trscit",
"trsib",
"trsibt",
"trsp",
"trspp",
"trspt",
"trsptx",
"trssi",
"trssit",
"tryh",
"tscin",
"tsibn",
"tspn",
"tssin",
"uces",
"ucfs",
"uemot",
"uemp",
"ufcbr",
"ufnfir",
"ufnir",
"ufpcm",
"ufpxm",
"uftcin",
"ugfdbt",
"ugsdbt",
"ugsint",
"ugssub",
"ujcca",
"ujccac",
"ujygfe",
"ujygfg",
"ujygse",
"ujygsg",
"ulef",
"ules",
"upcpi",
"upcpix",
"upgfl",
"upgsl",
"upkpd",
"upmp",
"upxnfb",
"uqpct",
"uveoa",
"uvpd",
"uvpi",
"uvps",
"uxeng",
"uxnfbt",
"uyd",
"uyhi",
"uyhln",
"uyhptn",
"uyhsn",
"uyhtn",
"uyl",
"uyni",
"uynicp",
"uyp",
"uysen",
"veo",
"veoa",
"vpd",
"vpi",
"vps",
"wdnfcn",
"wpo",
"wpon",
"wps",
"wpsn",
"xeng",
"xfs",
"xfsn",
"xg",
"xgap",
"xgap2",
"xgde",
"xgden",
"xgdi",
"xgdin",
"xgdo",
"xgdp",
"xgdpn",
"xgdpt",
"xgdptn",
"xgn",
"xgo",
"xgpot",
"xnfb",
"xnfbn",
"xnfbo",
"xnfbt",
"xp",
"xpn",
"ycsn",
"ydn",
"ygfsn",
"ygssn",
"yh",
"yhgap",
"yhibn",
"yhin",
"yhl",
"yhln",
"yhp",
"yhpcd",
"yhpgap",
"yhpntn",
"yhpshr",
"yhptn",
"yhshr",
"yhsn",
"yht",
"yhtgap",
"yhtn",
"yhtshr",
"ykin",
"ykpdn",
"ykpsn",
"ymsdn",
"ynicpn",
"ynidn",
"yniin",
"yniln",
"ynin",
"ynisen",
"ypn",
"zdivgr",
"zecd",
"zeco",
"zeh",
"zgap05",
"zgap10",
"zgap30",
"zgapc2",
"zlhp",
"zpi10",
"zpi10f",
"zpi5",
"zpib5",
"zpic30",
"zpic58",
"zpicxfe",
"zpieci",
"zrff10",
"zrff30",
"zrff5",
"zvpd",
"zvpi",
"zvps",
"zxnfbd",
"zxnfbi",
"zxnfbs",
"zyh",
"zyhp",
"zyhpst",
"zyhst",
"zyht",
"zyhtst",
"zynid",
]

var handleVariableClick = function(variable) {console.log(variable);};

React.renderComponent(
  <VariableSearch handleVariableClick={handleVariableClick} list={testlist} />,
  document.getElementById('container')
);

Can you replicate this bug? It is bothering me, but I can't figure out what's causing it (I will continue to look, however).

Anyways, thanks for the great work so far. I'm happy to help, but my javascript skills aren't excellent (yet).

Set placeholder

How can I set placeholder and other options in placeholder?

In the code I cannot see that option

Thanks

Elements should know if the spread operator is used

The only bug number that I have memorized at this point is #140. It keeps coming up, and maintaining the ever-growing whitelist is infuriating.

As a baby step toward fixing that bug, I think it would be nice to know if the spread operator is used during element creation, since this is the primary way that attributes could be accidentally passed to an element. We could then only enforce the whitelist on elements that are using the spread operator, as a baby step toward eliminating the whitelist altogether. In order to do this though, I think we need to modify the transform (Babel?), right? Do we want to file a bug against them?

This issue is mostly exploratory, to get an idea of what would need to be involved to do this effectively. RFC: @spicyj, @sebmarkbadge

Problems with default value

The component does not set a default value if the data came after rendering. For quick reference just replace getInitialState method in basic example with this one:

  getInitialState: function() {
      var self = this;

      setTimeout(function() {
          self.setState({states: states});
      }, 400);
    return {
      // the data the user can select from
      states: [],
      // the current selection
      selectedStateId: 'AL'
    };
  }

event var empty

The event var is structured but empty in the following code, can't find out what's wrong.

<Autocomplete
    items={this.state.autocompletedStations}
    onSelect={() => {
        this.setState({
            autocompletedStations: []
        });
    }}
    onChange={this.stationsAutocompleteChange.bind(this)}
    renderItem={this.renderAutocompleteItem.bind(this)}
    getItemValue={station => station.crsCode}
    inputProps={{ className: 'station-entry' }}
/>
stationsAutocompleteChange(event, value) { console.log(event) }
0: SyntheticEvent
_dispatchIDs: null
_dispatchListeners: null
bubbles: null
cancelable: null
currentTarget: null
defaultPrevented: null
dispatchConfig: null
dispatchMarker: null
eventPhase: null
isDefaultPrevented: ()
isPropagationStopped: ()
isTrusted: null
nativeEvent: null
target: null
timeStamp: null
type: null
__proto__: SyntheticEvent

Should your component be controlled?

You works with controlled component and update value via props.value

value={this.props.value}

May it would be better to use uncontrolled components approach when you set nothing except default value if it is needed?

return <input type="text" defaultValue="Hello!" />

And set value from dropdown box if an action happens.

Required ARIA children role not present: listbox textbox

Checks all elements that contain a WAI-ARIA role to ensure that all required children roles are present
(More Info)

wcag2a wcag411 

Target: #container > div > div > input
HTML:

Summary:
Fix any of the following:

Required ARIA children role not present: listbox textbox

add Option Categories

Add option categories, so we can present users with different sorts of options. This is well-supported in other autocomplete widgets.

This will require abstracting away the code to get widget DOM elements a bit. Right now you can add arbitrary elements to the combobox, but focusNext() and focusPrevious() will focus them, and they can then be selected.

Completely unusable if dependencies are up-to-date

I installed this component and spent about 4 hours straight trying to make it work, only to finally realize that it is completely unusable with up-to-date dependencies (like you would have if you start writing a React app from scratch with npm init && npm install --save react react-autocomplete jsx-loader webpack).

To demonstrate the problem, from a clean clone of react-autocomplete, apply the following patch:

diff --git a/examples/basic/main.js b/examples/basic/main.js
index 0aaa8b2..4c0d85b 100644
--- a/examples/basic/main.js
+++ b/examples/basic/main.js
@@ -1,7 +1,7 @@
 /** @jsx React.DOM */
 var React = require('react');
-//var Autocomplete = require('react-autocomplete');
-var Autocomplete = require('../../lib/main');
+var Autocomplete = require('react-autocomplete');
+//var Autocomplete = require('../../lib/main');
 var Combobox = Autocomplete.Combobox;
 var ComboboxOption = Autocomplete.Option;
 var states = require('../states');
diff --git a/package.json b/package.json
index 94b06bc..442d330 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
 {
-  "name": "react-autocomplete",
+  "name": "react-autocomplete-examples",
   "version": "0.0.2",
   "description": "",
   "main": "lib/main.js",
@@ -9,12 +9,13 @@
   "author": "",
   "license": "MIT",
   "dependencies": {
-    "react": "^0.10.0"
+    "react": "^0.12.2",
+    "react-autocomplete": "0.0.2"
   },
   "devDependencies": {
-    "jsx-loader": "^0.10.2",
-    "webpack": "^1.3.0-beta5",
-    "rf-release": "^0.1.2"
+    "jsx-loader": "^0.12.2",
+    "webpack": "^1.6.0",
+    "rf-release": "^0.4.0"
   },
   "tags": [
     "react",

Then run npm install and webpack, open examples/basic/index.html in a browser, and note that the combo box doesn't even appear. Instead, all the options are vomited to the screen with the word UNMOUNTED separating them:

UTALALAlabamaUNMOUNTEDAKAKAlaskaUNMOUNTEDAZAZArizonaUNMOUNTEDARARArkansasUNMOUNTEDCACACaliforniaUNMOUNTEDCOCOColoradoUNMOUNTEDCTCTConnecticutUNMOUNTEDDEDEDelawareUNMOUNTEDFLFLFloridaUNMOUNTEDGAGAGeorgiaUNMOUNTEDHIHIHawaiiUNMOUNTEDIDIDIdahoUNMOUNTEDILILIllinoisUNMOUNTEDININIndianaUNMOUNTEDIAIAIowaUNMOUNTEDKSKSKansasUNMOUNTEDKYKYKentuckyUNMOUNTEDLALALouisianaUNMOUNTEDMEMEMaineUNMOUNTEDMDMDMarylandUNMOUNTEDMAMAMassachusettsUNMOUNTEDMIMIMichiganUNMOUNTEDMNMNMinnesotaUNMOUNTEDMSMSMississippiUNMOUNTEDMOMOMissouriUNMOUNTEDMTMTMontanaUNMOUNTEDNENENebraskaUNMOUNTEDNVNVNevadaUNMOUNTEDNHNHNew HampshireUNMOUNTEDNJNJNew JerseyUNMOUNTEDNMNMNew MexicoUNMOUNTEDNYNYNew YorkUNMOUNTEDNCNCNorth CarolinaUNMOUNTEDNDNDNorth DakotaUNMOUNTEDOHOHOhioUNMOUNTEDOKOKOklahomaUNMOUNTEDOROROregonUNMOUNTEDPAPAPennsylvaniaUNMOUNTEDRIRIRhode IslandUNMOUNTEDSCSCSouth CarolinaUNMOUNTEDSDSDSouth DakotaUNMOUNTEDTNTNTennesseeUNMOUNTEDTXTXTexasUNMOUNTEDUTUTUtahUNMOUNTEDVTVTVermontUNMOUNTEDVAVAVirginiaUNMOUNTEDWAWAWashingtonUNMOUNTEDWVWVWest VirginiaUNMOUNTEDWIWIWisconsinUNMOUNTEDWYWYWyomingUNMOUNTEDUNMOUNTED

Please at least put up a big warning that react-autocomplete is incompatible with the current versions of react and jsx-loader, so that no one else tries to use this broken component by mistake.

Trigger event with query when Enter key is pressed

I'd like to be able to retrieve the query even when the Enter key is pressed, even when an autocomplete option isn't selected, so that the user can submit queries that aren't in the autocomplete options.

npm start fails with rackt error on tag v0.1.4

On trying to get the examples to work I tried npm i && npm start and it errored out. Relevant error messages:

Failed at the [email protected] start script 'rackt server'.
Tell the author that this fails on your system:
rackt server

Upon trying node_modules/rackt-cli/bin/rack server I get the following error message:

.../node_modules/rackt-cli/bin/../tasks/server: line 5: .../node_modules/rackt-cli/bin/..//node_modules/.bin/webpack-dev-server: No such file or directory

Local folder structure redacted for clarity.

Seems related to #51

Unexpected token in combobox.js

I've npm install react-autocomplete. but when I gulp, I get this:

events.js:72
throw er; // Unhandled 'error' event
^
Error: Parsing file /Users/oriharel/oriApp/sixdegrees/node_modules/react-autocomplete/lib/combobox.js: Unexpected token (358:6)
at Deps.parseDeps (/Users/oriharel/oriApp/sixdegrees/node_modules/browserify/node_modules/module-deps/index.js:418:28)
at fromSource (/Users/oriharel/oriApp/sixdegrees/node_modules/browserify/node_modules/module-deps/index.js:361:48)
at /Users/oriharel/oriApp/sixdegrees/node_modules/browserify/node_modules/module-deps/index.js:356:17
at ConcatStream. (/Users/oriharel/oriApp/sixdegrees/node_modules/browserify/node_modules/concat-stream/index.js:32:43)
at ConcatStream.EventEmitter.emit (events.js:117:20)
at finishMaybe (/Users/oriharel/oriApp/sixdegrees/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:460:14)
at endWritable (/Users/oriharel/oriApp/sixdegrees/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:469:3)
at ConcatStream.Writable.end (/Users/oriharel/oriApp/sixdegrees/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:436:5)
at DuplexWrapper.onend (/Users/oriharel/oriApp/sixdegrees/node_modules/browserify/node_modules/readable-stream/lib/_stream_readable.js:537:10)
at DuplexWrapper.g (events.js:180:16)
at DuplexWrapper.EventEmitter.emit (events.js:117:20)
at /Users/oriharel/oriApp/sixdegrees/node_modules/browserify/node_modules/readable-stream/lib/_stream_readable.js:934:16
at process._tickCallback (node.js:415:13)

It looks like I'm expected to react transform the combobox jsx to js. but it's in the node_modules.
So, is this the case and if so, how to add the task to do it?

Migrate to rackt eslint config

https://github.com/rackt/eslint-config-rackt contains a starting point that all org repos can build off of. This can be introduced by first using the config and overriding any rules that the repo doesn't comply with, without having to change any of the source. Then for non-controversial rules, PRs can be made to update the source to comply.

Here's the initial PR: #55

Android: Delete doesn't work as expected

Nexus 5, delete issue

It's hard to show this issue but I have captured it via USB debugging. When you try and delete the last letter it doesn't change the value, then (seemingly) randomly after a certain amount of attempts it will delete the whole field.

You can see on the right hand side when the elements flash I am typing in the box.

react-autocomplete

How set auto complete to empty

I have a drop down representing the countries and auto complete representing the cities.
When I change country I want auto complete to be empty no matter was there previously.
Currently
How to achieve that ?

 // My render
  render: function() {
    return (
      <div className="form-field">
        <label className="form-field__label">Location</label>
        <div className="form-field__value">
          <div className="selectcontainer">
            <select className="input-select"
                ref='country'
                value={this.props.country}
                onChange={this.onCountry}>
              {countries.map(function(d){
                return (<option key={d.code}  value={d.code}>{d.name}</option>);
              })}
            </select>
          </div>
          (<Autocomplete
             ref="city"
             defaultValue={this.props.city} 
             getItemValue={R.identity}
             onChange={this.onChange}
             onSelect={this.onChange}
             items={this.props.cities}
             renderItem={function (city) {
               return (<div key={city} >{city}</div>);
             }} />)
        </div>
      </div>
    );
  }

Immutablejs support

It seems to be mostly working out of the box, but I ran into one bug--the Enter key down handler pulls the highlighted item out of the list with square brackets:
this.getFilteredItems()[this.state.highlightedIndex]
Would you be willing to change this to:
this.getFilteredItems().get(this.state.highlightedIndex)

[release] 1.0.0 - Main thread

From another issue comment from @CMTegner, here's the general 'remaining tasks before v1' list.

@sprjr good to have you back! Here's my take on v1:

Blockers

#94
Nice-to-have (bugfixes, changes, improvements)

52

#68
#84
#92
#93
#103
#104
#106
There's a couple of topics we need to address either before v1 or soon thereafter:

Menu styling/positioning: The current implementation and default setup is not great. I'm tempted to just ditch it all and force the user to decide how to render the menu (we'll provide offset and other meta data). The alternative is to go for a relatively positioned menu, which we could easily do since we wrap both the input and the menu with a div. I could mock up both suggestions unless you have a better suggestion. Here are some issues for reference: #69, #70, #75, #100, #102
highlightedIndex: #52 and #106 try to fix some of the issues, but the fact is that highlightedIndex isn't updated when props.items changes. This needs to be fixed properly.
To be closed (already fixed, no longer applicable, etc)

13

15

30

45

50

53

64

74

95

97

99

105

  • more, these were just the obvious ones

Control opening direction up/down

Hi!
Is there a way to control the opening direction programmatically?
kinda like the native select tag, opens up or down.
thanks!

typing with async options gets funky

if you wrap the example's setState({states: ... in a setTimeout and then use it, things get weird pretty easily, haven't identified what exactly is happening.

use .jsx file extension

Hi,

I would like to suggest to use the .jsx file extension for files with jsx syntax. It makes handling with build systems easier, at least for me.

New API proposal

I've just read your complain on twitter, and inspired by react-radio-group, I've come up with the following API:

<AutoComplete
  onSelect={doSomething}
  onSearchTermChange={(query, next)=> queryOptions(query).then(next) }
  children={(state, controls)=>
    /*
      `controls` provides callbacks to control AutoComplete, such as setQuery,
      unfocusOption, focusNextOption and focusPrevOption. Also, it can provide the
      `navigateByKeyboad`, which will handle the up and down keys and enter.

      unfocusOption, will unfocus the current focused option.
    */
    <input
      type="search"
      name="query"
      value={state.query}
      onChange={controls.setQuery}
      onKeyPress={controls.navigateByKeyboard}
    />
    { state.async && state.isLoading? <LoadingIcon />:

      {/* `Popup` is a dumb vendor component */}
      <Popup>
        {state.options?
          state.options.map(({option, state, controls})=>
            <div
              key={option.id}
              {/*
                `controls` here could have the AutoComplete `controls` bound to
                current option, such as focusOption, focusNextOption, focusPrevOption,
                selectOption, all with no arguments, so it can be event callbacks
              */}
              onClick={controls.select}
              onMouseEnter={controls.focus}
              onMouseLeave={controls.unfocus}

              className={(state.isFocused? "focused ":"")+(state.isSelected? "selected": "")}

              {/* `option`  could be of any type */}
              children={option.value} 
            />
          )
        :`No valid options for ${query}.`}
      </Popup>
    }
}/>

What do you think?

Add copyright comment?

For IG I was able to get away without making any changes to this component except adding a big comment block indicating the copyright of the component. What's the best practice here? Should it be included in combobox.js?

displayName on combobox

combobox component is missing its displayName (making quick notes as I start to bring this in)

Make text selection configurable

Autocomplete is fully not usable on mobile devices. Entering a new symbol clears selection, but not adds letter. Need to type letter twice.

ezgif com-video-to-gif 1

On some devices after second typing, letter duplicated.

The examples are not working

I just tried out the library. It's excellent, one thing though - the example files seem to be incomplete and broken.

<!doctype html>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>react component</title>
<link href="app.css" rel="stylesheet"/>
<body>
  <div id="container"></div>
  <script src="../__build__/shared.js"></script>
  <script src="../__build__/static-data.js"></script>

Static-data example doesn't work on tag v0.1.4

I've recently adopted a codebase that uses v0.1.4 and so am trying to wrap my head around how it works. I downloaded the zip of the archive and opened examples/static-data/index.html in Chrome. According to the Network tab the following files 404:

  • examples/build/shared.js
  • examples/build/static-data.js

static-data.js is in the same folder so I could easily fix the path in index.html but I don't see shared.js anywhere. I tried npm i && npm start as mentioned in #46 but still no luck (I've reported that issue as well at #107).

`showButton` prop

When building a typeahead I don't want to show the down arrow, would be nice if it were customizable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.