Skip to content

onClick event for 'X' button on TextInput component #2479

Closed Answered by BRIDGE-AI
BRIDGE-AI asked this question in PrimeReact
Discussion options

You must be logged in to vote

Thank you, @melloware

I've write this code by refering your comment.
It works fine for me.

const Page = (...) => {
    ...

    const [globalFilter, setGlobalFilter] = useState(null);
    const textInputRef = useRef(null);

    useEffect(() => {
        const func = (e) => {
            if (e.currentTarget.value == '') {
                onGlobalFilterChange(e.currentTarget.value);
            }
        }

        textInputRef.current.removeEventListener('search', func)
        textInputRef.current.addEventListener('search', func)
    }, [onGlobalFilterChange]);

    ...
}
                ...

                <InputText type="search"
                    ref={textInputRef}
                    

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by melloware
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Workaround Workaround for the issue is found
2 participants