From 0716735655d6b03912942e1287b0fd057633d94f Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 3 Aug 2023 05:10:54 -0700 Subject: [PATCH] Fix positioning of the target selection dialog. The logic must differ slightly between clicking the button in the inspection widget vs selecting it from a context menu. Using showUnderneathOf in the case of the context menu causes the popup to show underneath the entire menu which seems wrong. PiperOrigin-RevId: 553442799 --- ...erySyncInspectionWidgetActionProvider.java | 5 +- .../qsync/action/BuildDependenciesAction.java | 3 +- .../BuildDependenciesForOpenFilesAction.java | 3 +- .../qsync/action/BuildDependenciesHelper.java | 57 +++++++++++++++---- 4 files changed, 54 insertions(+), 14 deletions(-) diff --git a/base/src/com/google/idea/blaze/base/qsync/QuerySyncInspectionWidgetActionProvider.java b/base/src/com/google/idea/blaze/base/qsync/QuerySyncInspectionWidgetActionProvider.java index 8f43d527295..ec52d3cc51e 100644 --- a/base/src/com/google/idea/blaze/base/qsync/QuerySyncInspectionWidgetActionProvider.java +++ b/base/src/com/google/idea/blaze/base/qsync/QuerySyncInspectionWidgetActionProvider.java @@ -16,6 +16,7 @@ package com.google.idea.blaze.base.qsync; import com.google.idea.blaze.base.qsync.action.BuildDependenciesHelper; +import com.google.idea.blaze.base.qsync.action.BuildDependenciesHelper.PopupPosititioner; import com.google.idea.blaze.base.qsync.settings.QuerySyncConfigurable; import com.google.idea.blaze.base.qsync.settings.QuerySyncSettings; import com.google.idea.blaze.base.settings.Blaze; @@ -86,10 +87,10 @@ public BuildDependencies(@NotNull Editor editor) { buildDepsHelper = new BuildDependenciesHelper(editor.getProject()); } - @Override public void actionPerformed(@NotNull AnActionEvent e) { - buildDepsHelper.enableAnalysis(e); + buildDepsHelper.enableAnalysis( + e, PopupPosititioner.showUnderneathClickedComponentOrCentered(e)); } @Override diff --git a/base/src/com/google/idea/blaze/base/qsync/action/BuildDependenciesAction.java b/base/src/com/google/idea/blaze/base/qsync/action/BuildDependenciesAction.java index 3c57ee3feeb..d250bc6648d 100644 --- a/base/src/com/google/idea/blaze/base/qsync/action/BuildDependenciesAction.java +++ b/base/src/com/google/idea/blaze/base/qsync/action/BuildDependenciesAction.java @@ -16,6 +16,7 @@ package com.google.idea.blaze.base.qsync.action; import com.google.idea.blaze.base.actions.BlazeProjectAction; +import com.google.idea.blaze.base.qsync.action.BuildDependenciesHelper.PopupPosititioner; import com.google.idea.blaze.base.scope.BlazeContext; import com.intellij.icons.AllIcons.Actions; import com.intellij.openapi.actionSystem.ActionUpdateThread; @@ -72,6 +73,6 @@ protected void updateForBlazeProject(Project project, AnActionEvent e) { @Override protected void actionPerformedInBlazeProject(Project project, AnActionEvent e) { BuildDependenciesHelper helper = new BuildDependenciesHelper(project); - helper.enableAnalysis(e); + helper.enableAnalysis(e, PopupPosititioner.showAtMousePointerOrCentered(e)); } } diff --git a/base/src/com/google/idea/blaze/base/qsync/action/BuildDependenciesForOpenFilesAction.java b/base/src/com/google/idea/blaze/base/qsync/action/BuildDependenciesForOpenFilesAction.java index b57614dcaa1..2f9cecde905 100644 --- a/base/src/com/google/idea/blaze/base/qsync/action/BuildDependenciesForOpenFilesAction.java +++ b/base/src/com/google/idea/blaze/base/qsync/action/BuildDependenciesForOpenFilesAction.java @@ -22,6 +22,7 @@ import com.google.common.collect.Iterables; import com.google.idea.blaze.base.actions.BlazeProjectAction; import com.google.idea.blaze.base.qsync.TargetsToBuild; +import com.google.idea.blaze.base.qsync.action.BuildDependenciesHelper.PopupPosititioner; import com.google.idea.blaze.common.Label; import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnActionEvent; @@ -81,7 +82,7 @@ protected void actionPerformedInBlazeProject(Project project, AnActionEvent even helper.chooseTargetToBuildFor( targetsToBuild.get(ambiguousOne), ambiguousOne, - event, + PopupPosititioner.showAtMousePointerOrCentered(event), chosen -> helper.enableAnalysis( ImmutableSet.