Fix null pointer exception when no component is selected