Clear Text on single tap

When I click on the cross icon first time, it lowers the keyboard and on the second tap, it clears the text in the search bar. I wanted to clear the text on the first tap I have tried other solutions …