I have a Link to web type link with a checkbox Open in new tab unchecked. In the API response there is no attribute to represent this choice. (However, if I check the checkbox it returns a target property)
I pass the field data to the
<PrismicLink> component from
@prismicio/react and it renders a link which opens in new page.
I pass a field data without the Open in new tab checked the component renders a Link which opens in the same tab.
I pass a field data with the Open in new tab checked the component renders a Link which opens a new tab.
Hey @andrzej1, welcome to the community.
There are two main reasons why this happens: either the target wasn't correctly saved in the field, or the version of the kit @prismicio/react is not on the latest version.
I checked I use the latest version of the library. How can I make sure the target field is saved correctly?
The best way is by looking for the doc in the API browser of your repo: https://your-repo-name.prismic.io/api/v2. You can share your endpoint with us, and we can check simultaneously. What's your Custom Type's name and the field's API ID?
This is the exact post I am talking about: https://scottlogic.prismic.io/api/v2/documents/search?ref=Y5nJxhEAACEAXKPm&q=[[at(my.page.title%2C"Software+Development+Careers+at+Scott+Logic")]]&src=apibrowser#format=json
In the slices you should check the first slice (page_title) and there is a field called
btn_link. Now just two fields are there:
url=https.... The checkbox is not checked on the Prismic admin. If i check the checkbox the field called
target will appear in the api response.
Ok so if the target appears in the API response, it means the issue is on the front-end. How are you handing internal links inside the project? aside from using the components from the kit.
Correct me if I am wrong, but i cannot see the target here:
And this field keeps opening in a new tab in the application?
Could you use a screen recording to exemplify it?
There is a link in the PageTitle slice, which looks like this in the code:
prismicH.isFilled.keyText(slice.primary.cta_label) && (
PrismicLink is imported from the latest version of the lib. The Open in new tab is not checked.
Result: Meet our Glasgow team | Scott Logic (Click on the View our vacancies link in the header)
That's odd, is your project in GitHub? I could take a look at the code to try and find the issue.
You can send the details via dm if you prefer.