I'm fairly sure I've said this before here and elsewhere, but bears repeating, especially for this post.
Statecharts is currently probably the most undervalued tool when it comes to programming GUIs with state. Statecharts are a continuation of state machines, but with less footguns and better abstractions to be able to build larger systems.
In the end, you either build a GUI that are using state machines implicitly, or explicitly. Tends to be less prone to bugs if you do so explicitly.
If you're interested, here is some starting points (copied from an older comment of mine):
And finally a very well made JS library by David Khourshid that gives you lots of power leveraging statecharts: https://github.com/davidkpiano
While we're at it, here are some links to previous submissions on HN regarding statecharts with lots of useful and interesting information/experiences:
great comments on statecharts previously here https://news.ycombinator.com/item?id=15835005
the top few comments i find compellingly skeptical.
https://news.ycombinator.com/item?id=15835482
https://news.ycombinator.com/item?id=15835666