Hi everyone, I have a question about dynamically controlling the “open in new tab” behavior.
I’m trying to use a prop (openInANewTab) to open a link in a new tab when it’s set to true. However, it’s not working as expected.
If I hardcode the value to true, it works perfectly and opens the link in a new tab. But when I pass the value dynamically through the prop, it doesn’t open in a new tab.
The component is reused across multiple pages, so I’m wondering if that could be affecting the behavior.
Has anyone encountered a similar issue or have any idea what might be going wrong?
After investigation, I discovered that the issue is that the prop Open in new tab? is not actually a boolean prop under the hood, but a string prop. We added the boolean prop editor to make it easier for the users to use, but ended up causing this confusion.
I will be making changes in the UI to make this clearer. For you to fix the issue, you will need to change the dynamic expression from $props.openInANewTab to $props.openInANewTab ? "_blank" : undefined. LMK if this solved your problem.