Giter Site home page Giter Site logo

Required input attr about react-geosuggest HOT 14 CLOSED

ubilabs avatar ubilabs commented on July 19, 2024
Required input attr

from react-geosuggest.

Comments (14)

ro-ka avatar ro-ka commented on July 19, 2024

I suppose there should be a required attribute attached to the input, right?

from react-geosuggest.

cezarsmpio avatar cezarsmpio commented on July 19, 2024

Yes, the result code would be:

<div class="geosuggest ">
    <input class="geosuggest__input " type="text" value="" placeholder="Start location" required>
    <ul class="geosuggest__suggests geosuggest__suggests--hidden"></ul>
</div>

You can use spread operator, something like <input {...this.props} />

from react-geosuggest.

ro-ka avatar ro-ka commented on July 19, 2024

Ah, okay, will add.

from react-geosuggest.

cezarsmpio avatar cezarsmpio commented on July 19, 2024

Something like:

<input
  className={'geosuggest__input ' + this.props.inputClassName}
  ref="geosuggestInput"
  type="text"
  value={this.state.userInput}
  placeholder={this.props.placeholder}
  disabled={this.props.disabled}
  onKeyDown={this.onInputKeyDown}
  onChange={this.onInputChange}
  onFocus={this.onFocus}
  onBlur={this.hideSuggests}
  {...this.props}
/>

from react-geosuggest.

ro-ka avatar ro-ka commented on July 19, 2024

I wouldn’t put all the props on the element. I think a whitelist with supported attributes it the better way.

from react-geosuggest.

cezarsmpio avatar cezarsmpio commented on July 19, 2024

You can create other prop like isRequired={true}, for example.

<Geosuggest isRequired />

from react-geosuggest.

wedneyyuri avatar wedneyyuri commented on July 19, 2024

@ro-ka Are you already working on this? I also need this feature. I can do a pull request for you.

from react-geosuggest.

wedneyyuri avatar wedneyyuri commented on July 19, 2024

@ro-ka What do you think about including other attributes like autocomplete, name, id, etc...

The solution proposed by @CezarLuiz0 seems to solve this problem, in my opinion the component should not know all the properties assigned to the input element.

from react-geosuggest.

ro-ka avatar ro-ka commented on July 19, 2024

Will add, yes. No time till now. :)
That’s true, but it’ll attach a lot of non standard attributes to the input element. Will a whitelist with attributes that are defined in the spec to add.

from react-geosuggest.

ro-ka avatar ro-ka commented on July 19, 2024

Released as 1.15.0. Thanks for bringing this up!

from react-geosuggest.

cezarsmpio avatar cezarsmpio commented on July 19, 2024

Awesome! 👍

from react-geosuggest.

wedneyyuri avatar wedneyyuri commented on July 19, 2024

@ro-ka I think it's missing the id attribute.

That's the case:

<label for="place">Search Places</label>

from react-geosuggest.

ro-ka avatar ro-ka commented on July 19, 2024

Totally, will fix that!

from react-geosuggest.

ro-ka avatar ro-ka commented on July 19, 2024

Fixed in 1.15.1. Thanks! :)

from react-geosuggest.

Related Issues (20)

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.