An Office service that supports add-ins to interact with objects in Office client applications.
Hello Nguyễn Trọng Cảnh
Thank you for reaching out to Microsoft Q&A about the Outlook add-in behavior. The issue typically stems from fixed positioning that fails to adjust for scroll offsets or the limits of the add-in's iframe/webview container; Or outlook's habit of refreshing its UI during scroll events, such as in the email list, which can throw off the positioning references for elements attached to the document body. Here something you can do to fix this:
Use Native Manifest-Defined Menus for Simple Dropdowns: If your dropdown is static (a list of options triggering functions), define it in your add-in's manifest.xml. This lets Outlook handle positioning natively, avoiding custom JS/CSS issues.
<Control xsi:type="Menu" id="MyDropdown">
<Label resid="MyDropdownLabel" />
<Items>
<Item id="Item1">
<Label resid="Item1Label" />
<Action xsi:type="ExecuteFunction">
<FunctionName>myFunction1</FunctionName>
</Action>
</Item>
<!-- Add more items -->
</Items>
</Control>
Reference: https://learn.microsoft.com/en-us/office/dev/add-ins/design/add-in-commands
If you need a dynamic dropdown, calculate positions relative to the button and reposition on scroll.
function showDropdown(buttonElement) {
const dropdown = document.getElementById('myDropdown');
const rect = buttonElement.getBoundingClientRect();
dropdown.style.position = 'absolute';
dropdown.style.top = `${rect.bottom + window.scrollY}px`;
dropdown.style.left = `${rect.left + window.scrollX}px`;
dropdown.style.display = 'block';
// Reposition on scroll
const reposition = () => {
const newRect = buttonElement.getBoundingClientRect();
dropdown.style.top = `${newRect.bottom + window.scrollY}px`;
dropdown.style.left = `${newRect.left + window.scrollX}px`;
};
window.addEventListener('scroll', reposition, true);
// Clean up listener on close
}
Please test these in both Outlook web and desktop (ensure you're on the latest Microsoft 365 updates). Use browser dev tools (F12) to inspect coordinates post-scroll.
Hope this help.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.