Application hosting VST/AU plugins crashes at keyboard input when plugin window is in focus

I’m writing an application which hosts VST/AU plugins.

When I open up a juce::DocumentWindow which contains the plugin GUI inside it, and press keyboard key, I get a failed assertion. The assertion happens on line 2204 of file juce_mac_NSViewComponentPeer.mm:

jassertfalse; // The system should not attempt to insert text when there is no active TextInputTarget

How should I handle the plugin windows so that if they want keyboard input (for example for naming presets, etc.) that window can use the keyboard input. But otherwise the keyboard presses go to the main application, so it can react to starting / stopping the song when spacebar is pressed, etc.

It seems that when I add an extra juce::KeyListener to the DocumentWindow, the application doesn’t crash anymore.

I made my MainComponent a juce::KeyListener and returned “true” from:
bool keyPressed(const KeyPress& key, Component* originatingComponent).

That seems to prevent the crashes.
I’m not sure if some extra magic is required to make the plugins handle their own keyboard input properly, if they have some use for keyboard functions.

My issue solved itself when I added the MainComponent as keyboard listener, overriding both keyPressed() and keyStateChanged() from juce::KeyListener class.