Is there any way to restart a countdown or IEnumerator?

Hey Sorry if this is an obvious answer. I’m still new to c#.

So on my scene i have a chatbox gameobject which by default is set to SetActive(false).

And everytime the player presses “/” or “t” it will set the chatbox to true and allow the player to type in the inputbox.

Once the player presses enter, it will send the message to the other players on the server.
Basically, I want to have the box fade out and SetActive(false) after 7 seconds of sending the message.
I have done this by calling a IEnumerator which counts down from 7 seconds. Then it plays the fading animation and sets the gameobject to SetActive(false).
However, I would like the countdown to restart if the players sends another message or starts typing a new message before the timer is done. Is there any way to restart the IEnumerator or a better way to do this?? Also, how would i detect if the player has focused, or is typing into the Inputbox? Thank you in advance!

You could use the StopCoroutine("CoroutineName"); method to stop you already running coroutine when a new message is recieved and then start it again, effectively refreshing the countdown duration.

For checking if an inputField chatInputField is in focus, you can simply do
if(chatInputField.isFocused) { // logic here }

It would help if you show how exactly you’re calling the IEnumarator and handling the messages.