Allow links in forms to open in new tabs
We used to open these links in new tabs, but accidentally stopped doing
so in commit 75a28fafc.
While, in general, automatically opening a link in a new tab/window is a
bad idea, the exception comes when people are filling in a form and
there are links to pages that contain information which will help them
fill in a form.
There are mainly two advantages of this approach. First, it makes less
likely for people to accidentally lose the information they were filling
in. And, second, having both the form and a help page open at the same
time can make it easier to fill in the form.
However, opening these links in new tabs also has disadvantages, like
taking control away from people or making it harder to navigate through
pages when using a mobile phone.
So this is a compromise solution.
This commit is contained in:
@@ -13,6 +13,17 @@ describe ConsulFormBuilder do
|
||||
|
||||
let(:builder) { ConsulFormBuilder.new(:dummy, DummyModel.new, ApplicationController.new.view_context, {}) }
|
||||
|
||||
describe "label" do
|
||||
it "accepts links that open in a new window in its content" do
|
||||
render builder.text_field(:title, label: 'My <a href="/" target="_blank" title="New tab">title</a>')
|
||||
|
||||
expect(page).to have_link count: 1
|
||||
expect(page).to have_link "title"
|
||||
expect(page).to have_link "New tab"
|
||||
expect(page).to have_css "a[target=_blank]"
|
||||
end
|
||||
end
|
||||
|
||||
describe "hints" do
|
||||
it "does not generate hints by default" do
|
||||
render builder.text_field(:title)
|
||||
|
||||
Reference in New Issue
Block a user