-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getting a lock #15
Comments
While updating you can:
Those are two solutions I can quickly come up with. Let me know if it works out for you Cheers, |
I think I have the same problem. I use DebounceInput as a Searchfilter on a queryset. However, sometimes the value of the input is not correct.
Now this can be "solved" by removing the value attribute from the DebounceInput. I'm thinking, because DebounceInput is a controlled component (https://facebook.github.io/react/docs/forms.html). Is this even possible? |
That sounds like a bug (though a different one to the topic)
Do not modify DOM with any other tools other then React if you don't want to have completely unpredictable effects
It can be both =) If you don't specify Your use-case seems like an actually the main use-case for DebounceInput =). And the way we use it on our projects. So I am quite surprised it does not work as expected. Would be great to have a Codepen example to play with, so we can find what could be the issue |
Thank you for the quick reaction. maybe it's because I use the DebounceInput like so: ----- SearchBox.jsx -------
I can imagine there is a better way to extend DebounceInput. |
It is expected behavior with `minLength`. If you have it equal 2 and reduce
input to less then 2 (1 char), input is cleared.
I am actually struggling to figure out what sort of a problem you have.
Maybe you can ping me in Reactiflux or Gitter (button in readme)
|
Also, if you are doing wrapping, then look at https://github.com/nkbt/react-text-filter (it is basically wrapped I remember having some problems with it similar to what you are trying to explain. See examples there and the code of TextInput how it keeps behaviour exactly the same to what you want. |
Double-checked the code of Filter and there seems like no issues wrapping Debounce. Everything is simple. I had problems initially but then fixed DebounceInput to allow easy extending. So just look at it, maybe there is some tiny little thing that I do not notice in your code that makes things awkward... |
ahhh I think I know it. So, I have a component.This has a component In this TableFooter, there are searchboxes for each column. Entering text in one searchbox alters the resultset on Table, which probably also triggers a new draw on the TableFooter and hence the searchbox, overwriting the text the user was typing with the search word. For me to get it to work, is to move the search filters outside of the table which holds the result. I'm going to try this now. |
Oh cool! Let me know how it goes |
Separating the components didn't seem to matter in my code, because (I suspect) they still use the same store (flux), and on updating of the store all components were updated. So I think I have to read a bit more into flux and probably create more Stores or don't store the search value into the store but in the component itself. |
I am seeing a problem in a filter text box and typing relatively quickly. My on change function updates my redux store with the new value, but if I type a bit more quickly, the new characters tend to disappear. Tellingly, it improves the lower I set the debounceTimeout value. When I set it to 1, the glitch disappears entirely. Have you seen anything like that, or have any advice? |
@twmills this is how it works (or the reason it does not work as you expect it to work) in your case:
It is completely expected behaviour when you have delayed input. If you want to keep it in redux store and have "controllable" input with instant updates, then why do you need debounced-input in the first place? What is the desired behaviour for you? I can most likely help you to design it PS: if you want to set value of input when user opens the page from the last input - use |
I have a similar issue in different use case. My use case is DebouncedInput onChange will trigger AJAX to search data. The data received includes the search text. There are also other components on the page that would trigger the same AJAX call, but with different search text. The DebouncedInput has to reflect the search text when it receives the data. The AJAX might finish when the user is changing the DebouncedInput, causing the user's change to reset. To solve the problem, I've wrapped DebouncedInput in a component to ignore the search text if it was the same as what onChange was triggered with
|
@nkbt the scenario you described in your latest comment is exactly what I've run into.
In my application, I'm using redux and I expect the input's visible value to reflect the app (redux) state. Here's a possible API that I came up with: <DebounceInput
debounceTimeout={300}
value={this.props.value}
onChange={this.handleDebouncedChange} // Asynchronously update the server
onChangeImmediate={this.handleImmediateChange } // Update the app state
/> What do you think? UPDATE: Edited the API to be backwards-compatible |
I tried to use getInitialState() {
return {
value: this.props.value || ''
};
} Source: https://github.com/nkbt/react-debounce-input/blob/master/src/Component.js#L38 |
Hi,
I'm using react-infinite to render a column of data, and I use react-debounce-input for filtering the data. This works well most of the time. However, when a new piece of data comes through the pipeline, it gets automatically appended to the top of the list (via setState). Unfortunately what happens is that if the user is typing in a query while a piece of data is coming in, the search box gets scrambled (setState from the data column confuses the search query). Basically I need to add a LOCK such that if the user is in the middle of entering a query, the data column should not update. The problem is that I don't know how to get the lock from react-debounce-input? Any ideas?
I can control the setState from shouldComponentUpdate for react-infinite, but I'm not sure how to intercept the search box lock.
The text was updated successfully, but these errors were encountered: