refactor editor events into a more reusable pattern
fix tab switching regression