AnAction (@NotNull List<AnAction> actions) { if (IS_AUTOCLOSE_DISABLED || myAutoCloseActions == null || myAutoCloseActions.isEmpty() || actions.isEmpty() ) { return null; } for (AnAction autocloseAction: myAutoCloseActions) { // 1. if some of autoclose actions doesn't exist in actions then we must close this touchbar if (!actions.contains(autocloseAction)) { return autocloseAction; } // 2. if autoclose action is disabled (or hidden) then we must close this touchbar final @NotNull Presentation presentation = myFactory.getPresentation(autocloseAction); if (!presentation.isVisible() || !presentation.isEnabled()) { return autocloseAction; } } return null; }