Fix exiting from text edit mode

[#77905270]

It mainly fixes issues related to undo functionality.
Do not add new state to undo history if it's the same like the last one

[#77940994]