Spilled coffee is likely to build up in the drip tray, so make sure you're emptying and cleaning it regularly. Otherwise, ...
You don't have to dig deep through the menu to access the Undo button. It's available in Gboard's menu button (also known as ...