diff --git a/src/OutlookAddin/OutlookAddin.csproj b/src/OutlookAddin/OutlookAddin.csproj index 228a50d..f80fc66 100644 --- a/src/OutlookAddin/OutlookAddin.csproj +++ b/src/OutlookAddin/OutlookAddin.csproj @@ -36,7 +36,7 @@ C:\Users\Chaim\source\repos\OutlookAddin\Publish\ \\192.168.10.97\Projects\LegalCRM\Add-in\ en - 1.0.0.4 + 1.0.0.5 true true 7 @@ -270,9 +270,6 @@ OutlookAddin.Images.klear-compose.png - - OutlookAddin.Images.klear-attach.png - Code diff --git a/src/OutlookAddin/Ribbon/ExplorerRibbon.cs b/src/OutlookAddin/Ribbon/ExplorerRibbon.cs index 261b990..0ff3267 100644 --- a/src/OutlookAddin/Ribbon/ExplorerRibbon.cs +++ b/src/OutlookAddin/Ribbon/ExplorerRibbon.cs @@ -19,7 +19,15 @@ namespace OutlookAddin.Ribbon { private const string ExplorerResource = "OutlookAddin.Ribbon.ExplorerRibbon.xml"; private const string InspectorResource = "OutlookAddin.Ribbon.InspectorRibbon.xml"; - private const string FileButtonId = "FileToEspoCrm"; + + // Every button whose `getEnabled` depends on the current Explorer + // selection must be re-evaluated on every SelectionChange — Office + // caches the initial result otherwise and the button stays stuck. + private static readonly string[] SelectionDependentButtons = + { + "FileToEspoCrm", + "SaveAttachments" + }; private IRibbonUI? _explorerRibbon; private IRibbonUI? _inspectorRibbon; @@ -45,7 +53,7 @@ namespace OutlookAddin.Ribbon var explorer = Globals.ThisAddIn.Application.ActiveExplorer(); if (explorer != null) { - explorer.SelectionChange += () => _explorerRibbon?.InvalidateControl(FileButtonId); + explorer.SelectionChange += InvalidateSelectionDependentButtons; } } catch @@ -54,6 +62,16 @@ namespace OutlookAddin.Ribbon } } + private void InvalidateSelectionDependentButtons() + { + var ribbon = _explorerRibbon; + if (ribbon == null) return; + foreach (var id in SelectionDependentButtons) + { + try { ribbon.InvalidateControl(id); } catch { /* ignore */ } + } + } + public void OnInspectorRibbonLoad(IRibbonUI ribbon) { _inspectorRibbon = ribbon;