Change group state if Input isn't focused

Hi, Bubbler’s.

I’m making a todo list that has inline edit mode and the new value is saved “on the fly”, but if the initial value isn’t changed - textarea just stays active, which Is not what I want to achieve.
The only thing I need is to set the state of the group when I click everywhere on the page.In plain text my task sounds like something like:

“when inputname value hasn’t changed → set group’s statename to default”;
“When inputname isn’t focused → set group’s statename to default”

How can I do that?