Open MartinKavik opened 4 years ago
Hey, why should we ignore it ?
Here is the quote from the doc :
target Where to display the linked URL, as the name for a browsing context (a tab, window, or
_self: the current browsing context. (Default) _blank: usually a new tab, but users can configure browsers to open a new window instead. _parent: the parent browsing context of the current one. If no parent, behaves as _self. _top: the topmost browsing context (the "highest" context that’s an ancestor of the current one). If no ancestors, behaves as _self.
When you write attrs!{ At::Target => "_blank" }
, then you hope the link will be opened in a new tab. However Seed doesn't ignores it (if the link has a relative URL) and handles it as a regular link / route => it behaves exactly like _self
instead of _blank
.
P.S. There are also other exceptions that should be handled - e.g. when the user holds Control
key during the click, it should open a new tab, but it doesn't happen because Seed handles it as a regular link click.
But why can't it open a new tab?
But why can't it open a new tab?
Seed intercepts all relative links by default to prevent the app reloading. The intercepted link click doesn't propagate to the browser's handler so it doesn't process the link at all in such cases.
Taking things like target="_blank"
into account is basically a missing Seed feature.
Ah, okay. Now I understand. I wonder what should happen with the other target
values. Does seed have a concept for these "browsing contexts"? None that I am aware of. A simple solution to this problem might be to just stop intercepting any relative link calls with target=_blank
but the other target
values would still not be handled correctly.
But maybe that is just fine? I am not sure what a "browsing context" could be other than a browser page or an iframe. So I guess to handle target
properly, seed needs to provide some story for tabs and iframes.
I would just handle the most common cases - it means Ctrl key + click
and target="_blank"
. We can add special handling for other cases when somebody needs it - I would try to respect YAGNI.
Does seed have a concept for these "browsing contexts"? None that I am aware of.
There aren't any special concepts / apis for "browsing contexts".
Makes sense. I guess anything the other targets do can be emulated using other features.
See https://github.com/seed-rs/seed/blob/38f6c201206b9988abf60d9c399383e3734a6414/src/browser/service/routing.rs#L101
Should we ignore all links with set
target
or only with sometarget
values (e.g._self
)?MDN docs: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a
Workaround: