Comments (19)
Hi there,
Do you have any update on this?
from react-dadata-suggestions.
Hello.
I think for Final Form you could use the mutators
for passing values from react-dadata-suggestion event handler into final form's state. Here is an example
from react-dadata-suggestions.
Thank you very much for your reply! Yes, it works, but the input itself is cleared now.
from react-dadata-suggestions.
Yes it's empty. You should somehow pass the value into the query
attribute of Suggestions component. Sorry, I'm not familiar with Final Forms, so I can't help.
Also, I've just noticed the deprecation warning about mutators in my previous example, you should use form: mutators
instead of mutators
.
from react-dadata-suggestions.
@iloveip
Looks like it works
Also I fix deprecation warning.
from react-dadata-suggestions.
Thank you very much 🙏
from react-dadata-suggestions.
Hi there,
I've just noticed, that if you select an address (for example, with street), and then want to add a house, the input is cleared as soon as you start typing. (If you do the same with arrows up and down in the first place, everything is ok.) Is there any way to fix it?
from react-dadata-suggestions.
try
onChange={(event, value) => props.input.onChange({value: event})}
from react-dadata-suggestions.
Yes, now it works, thank you very much!
from react-dadata-suggestions.
I'm sorry, but I have one more question 🙏
In my example the suggestions list hides and shows on every key press as I type. Is there anyway to fix it?
from react-dadata-suggestions.
I doubt if it's possible in current implementation.
How it works: onChange
event handler set the new value for form field, then this value passed into query
prop of dadata component, and this causes componentWillReceiveProps
handler fired, which clears suggestions list.
I'll think how to improve this use-case.
from react-dadata-suggestions.
Ok, thank you very much.
from react-dadata-suggestions.
So-so. I know how to fix your issue, but I don't know how to preserve current behavior for other cases.
from react-dadata-suggestions.
Could you please share your solution? Maybe I can fork your repository and fix it only for me (if other users don't have such problem).
from react-dadata-suggestions.
something like this
diff --git a/src/index.js b/src/index.js
index a8f8b50..9d2f3e6 100644
--- a/src/index.js
+++ b/src/index.js
@@ -74,12 +74,11 @@ class DadataSuggestions extends Component {
}
componentWillReceiveProps(nextProps) {
- this.setState({
- query: nextProps.query,
- suggestions: [],
- showSuggestions: false,
- success: false,
- });
+ const newQuery = nextProps.query;
+ const { query } = this.props;
+ if (newQuery != query) {
+ this.handleChange(newQuery);
+ }
}
componentWillUnmount() {
@@ -126,8 +125,7 @@ class DadataSuggestions extends Component {
return searchWords;
};
- handleChange = (e) => {
- const query = e.target.value;
+ handleChange = (query) => {
const { deferRequestBy } = this.props;
this.clearFetchTimeout();
@@ -258,7 +256,7 @@ class DadataSuggestions extends Component {
return (
<div className="suggestions-container">
<QueryInput
- onChange={ this.handleChange }
+ onChange={ e => this.handleChange(e.target.value) }
placeholder={ this.props.placeholder }
loading={ loading }
query={ query }
from react-dadata-suggestions.
I've merged #25, please check release v1.1.0.
Just add new prop receivePropsBehaveLikeOnChange={true}
to dadata component in your code. There is example based on your last link from codesandbox.
Looks like it works.
upd. 😆 🤣 no, it still doesn't work. Now select event is broken 🤔
from react-dadata-suggestions.
Ok. So I just wait? Or I can go ahead and fix you repo as you said above?
from react-dadata-suggestions.
@iloveip check v1.1.1 please, I hope it works. Link is the same as previous
from react-dadata-suggestions.
😃Thank you very much! Everything works great now!
from react-dadata-suggestions.
Related Issues (20)
- Возможность отключить suggestions HOT 1
- Не работают touch ивенты HOT 2
- Why `dist` directory is not in repo? HOT 2
- breaking changes в версии 1.0.3
- Add a class name to the query input HOT 4
- Get location data HOT 1
- Problem with extracting onFocus event HOT 4
- How to add styles for suggestion highlighting HOT 4
- Styles for LIQUIDATED are not working HOT 5
- Initializing react-dadata-suggestions with data from the state HOT 24
- Выпадалка в body HOT 2
- Возможность указать приоритет города HOT 2
- Возможность передать input дополнительные параметры HOT 10
- Warning: Invalid DOM property `autocomplete`. Did you mean `autoComplete`? HOT 1
- Как передать атрибут id компоненту HOT 3
- Поддержка подсказок по ФИАС HOT 1
- `bounds` prop HOT 2
- Проблемы с определением ОКТМО для адресов в Санкт-Петербурге HOT 6
- Как связать эту библиотеку с useForm? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-dadata-suggestions.