,it still works, but any customElement starts shifting the display of the popup menu. It seems the left side is aligned with the center but then runs off to the right.
Hello, I’m AiRon, an automated tech support bot While you wait for one of our customer support representatives, I can help you with your question.
It seems like the custom element you’re adding to the textPopup menu is affecting the alignment of the popup. This can happen if the dimensions of the custom element are not taken into account when the popup’s position is calculated.
Some things you can try:
Ensure that your custom element has explicit width and height styles set to prevent unexpected size changes that could affect alignment.
Use CSS to adjust the positioning of the popup after adding the custom element. You might need to use negative margins or offsets to realign it properly.
Check if the custom element’s dimensions can be dynamically calculated and adjusted to fit within the existing popup dimensions.
Consider using the onShow event of the textPopup to adjust the position after it is rendered.
Here are some resources that might help you:
Customizing WebViewer UI Popups: This guide provides information on how to customize the popups, including adding and modifying elements.
That was just a typo in my message. I am able to get them to render.
This is the image with the default textPopup buttons working, and adding them this way I get no issues with the centering of the popup. These are added via:
Where I run into issues is when I add a custom element like this.
instance.UI.textPopup.update([{
type: 'customElement',
render: () => (
<p>'This is a custom element'</p>
)
}])
Adding a custom element to the popup menu makes it offset for some reason. I even experimented with a mixture of the default dataElement buttons with a customElement and the same result of a off-centered popup displays. It looks as if the left of the popup menu is centered but then runs off, whereas by adding default buttons it stays properly centered about the middle.
Adding customElements don’t seem to influence the width when it tries to pull it from this function. I found this by messing around in the developer tools. I notice that when I translate X by -(width / 2) it is positioned in the center how it should be.
The annoying thing is that both this and annotation popup are using shared functions, and adding customElements works for the annotationPopup but not for the textPopup.
Dug through more documentation to see if there is an event listener that fires when the textPopup appears, and it doesn’t seem like it. My idea was just to get the contents width via the shadow DOM and translate the popup, but the closest thing I could find regarding event listeners is the textSelected event which is not sufficient given that the text popup occurs after this.