Clear input field on mobile, remain focused-in state

Ive been trying to figure out a way for a mobile search input field to remain focused-in when you tap on a clear icon to clear the text input field, yet remain in the focused-in state. I can prototype it but I cant find a way to keep the keyboard from exiting and reentering. Ive tried to use a combination of responses when tapping the clear icon of text formula ““ for the input field and then focus-in to try and keep the input field in its active state. When testing on mobile is where I run into the keyboard exit and rentry. I could be overthinking something really obvious so was hoping someone has run into this. For desktop apps its no problem but trying to find a way to keep the keyboard on iOS device to remain up and the inout field to remain focused-in when you clear the search field.