verbb / hyper

A Craft CMS plugin for managing links, focusing on user experience.
Other
22 stars 14 forks source link

Setting "Default New Window" prevents target from working as expected #146

Open johnfmorton opened 5 months ago

johnfmorton commented 5 months ago

Describe the bug

When creating a new Hyper field, if I select "Default New Window" as true, the UX shows the New Window toggle as green. However, the Twig will not render "_blank" as expected.

Another issue I see may be related. In the field that has it's "Default New Window" as true, in the UX of the entry, you can toggle the value off, but it will always show "green" (true) when returning to the entry edit screen in the Craft control panel.its

Steps to reproduce

  1. Create a new Hyper field
  2. Default Link Type = "URL"
  3. Enable New Window = true
  4. Default New Window = true
  5. Add field to an entry type
  6. Create an entry and then view it on the front end, looking for the value of "target" on the Hyper field. It should be blank, even though New Window is true during the entry creation process.
  7. Go back to the entry edit page and attempt to turn off the New Window value.
  8. Save the entry
  9. Open the edit page again to find New Window set to true

Craft CMS version

4.9.0

Plugin version

1.1.28

Multi-site?

No

Additional context

No response

engram-design commented 5 months ago

So this is more of a UI issue than anything I believe. Thanks to the video you sent through privately, I can see the issue is that you're toggling the New Window setting, but leaving the link blank. This means that the value for the field is technically empty, so it's switching back to the defaults. This is the same reason why Twig will not render "_blank" as expected.

If you did the same thing with a value in the link field, I'm seeing it save correctly.

At your Step 6 when you view an entry, that link field has no value at that point, so it's not going to show a value for the link, or for the other settings.

This is very much related to https://github.com/verbb/hyper/issues/8 where we need to provide a better UI for the empty state to prevent this sort of behaviour. That's probably going to be slated for Hyper 2 for Craft 5, as it's now a breaking change.