React native custom autocomplete onBlur fires before onPress - reactjs

I have a TextInput component with a List Item component that displays a list of search suggestions below it, similar to an AutoComplete. The issue is when I click one of the suggestions from the list it first fires the onBlur method of the TextInput and requires a second press before it fires the onPress method. How do I call the onPress method in one tap? I don't want it to blur if I'm pressing a dropdown list item.

Related

Primeng dropdown firing onBlur event

I need to fire onBlur event for p-dropdown. I need this to be fired only when the dropdown looses focus. But its firing onBlur event even when I click on dropdown. I know there is 'onSelect' event but I cant use that.
My requirement is, User can either select a dropdown value or can enter any text which is not in dropdown. I need to save the info into DB.
I tried putting a settime but its not working out.

React Fire on Change event on load

I have a component that dynamically builds check boxes, from the result of an API call.
I am selecting the first radio button in a group, as a default, when the component is created.
Based on what radio button is checked/selected the page displays differently. So the radio button is selected after the page loads, but the onChange function does not get fired to display the page correctly. I am looking for a way to fire the onChange event after loading, API fetch, and displaying the radio buttons.
Thanks you helped me figure it out. In the final line of my useEffect hook, I click the first radio button in the group. That both sets the default and fires the change event. I tried setting it to check but that did not fire the change event.
useEffect(() => {
.
.
document.getElementsByName('rbImageGroup')[1].click();
}, []);

React remove blur onClick

I have a search box with an autocomplete wrapped around it using antd components and when the input is populated and you click the search button, the dropdown still shows. It doesnt hide itself. Here is the link to the codesandbox. These are the steps to reproduce:
Type in any text in the input.
click outside of the area on the black page to unfocus it
Click the search button
The dropdown shouldnt show again.

Material UI Autocomplete: Rendering inside custom Menu dropdown looses focus

So I took the example react-mui has in the docs about having the autocomplete inside a custom popover demo here, but I replaced the popover with the Menu component because the popover gets cropped inside modals.
So the minimal code is something like this
The problem I'm experiencing is that if you write something inside the input box, then use the arrow keys for selecting an item, the input box gets blurred and so the autocomplete resets it. this behavior doesn't happen when using a popover.
Any suggestion on how to keep the input focused even when selecting an item using the keyboard arrow keys?

onBlur is called from child elements

i have a container div that contains many inputs and checkboxes inside, i want to trigger an onBlur event only when the container div loses focus, instead the onBlur event is triggered everytime any element inside it loses focus
React documents this problem by utilizing the event loop with a setTimeout function with an empty second argument.

Resources