Skip to content

using direct link as opposed to popup for render token - #3

Open
davezuckerman wants to merge 2 commits into
ANW-2833from
ANW-2837-keyboard
Open

using direct link as opposed to popup for render token#3
davezuckerman wants to merge 2 commits into
ANW-2833from
ANW-2837-keyboard

Conversation

@davezuckerman

Copy link
Copy Markdown

Related Ticket (JIRA or GitHub Issue)

ANW-2837

Summary

Updated application_helper so render_token serves a direct link as opposed to a popup. This allows for keyboard navigation. aria_label is also provided for screen readers.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change, for example API endpoint renaming)
  • My change requires a change to the documentation - If so elaborate:

Checklist:

  • I have read and agree to the CONTRIBUTING document.
  • I have authority to submit this code. - See our licensing
  • Have you added tests to cover these changes? If not why:

@davezuckerman

Copy link
Copy Markdown
Author

After chatting with Jesse it sounds like creating a direct link as opposed to the current popup is the way to go. Even if I can get the popup to work with keyboard navigation it sounds like it wouldn't be following accessibility guidelines. render_token is used by several pages so this will apply to more than just the accessions view. I think this is better than having a "View" popup as currently implemented

@awilfox awilfox left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall love the change, it's going to solve a lot of the tickets! But I would like to hammer out a few things first.


html = "<div class='"
html += "token " if not opts[:inside_token_editor]
aria_label = CGI.escape_html(strip_tags(clean_mixed_content(opts[:label].to_s)))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ARIA label shouldn't be required if this is a plain link, because the user agent will infer the correct value from the link text.

link_opts[:class] = "token " unless opts[:inside_token_editor]
link_opts[:class] = "#{link_opts[:class]}#{opts[:type]}"
link_opts[:"aria-label"] = aria_label
link_opts[:tabindex] = 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be necessary since links are automatically focusable, unless token removes them?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so remove this whole section (95 - 98) if it's focusable without it and if so ignore the comment below regarding
link_opts[:class] = "#{'token ' unless opts[:inside_token_editor]}#{opts[:type]}"?

Comment on lines 100 to 106
html = ""

if opts[:icon_class]
html += "<span class='icon-token #{opts[:icon_class]}'></span>"
else
html += "<span class='icon-token'></span>"
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it will unconditionally be started either way, we can remove the initial set to a blank value and have it start with the icon.

Suggested change
html = ""
if opts[:icon_class]
html += "<span class='icon-token #{opts[:icon_class]}'></span>"
else
html += "<span class='icon-token'></span>"
end
if opts[:icon_class]
html = "<span class='icon-token #{opts[:icon_class]}'></span>"
else
html = "<span class='icon-token'></span>"
end

Comment on lines +95 to +96
link_opts[:class] = "token " unless opts[:inside_token_editor]
link_opts[:class] = "#{link_opts[:class]}#{opts[:type]}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the fence on whether this is better or not. It's slightly less confusing, but it does feel a bit uglier.

Suggested change
link_opts[:class] = "token " unless opts[:inside_token_editor]
link_opts[:class] = "#{link_opts[:class]}#{opts[:type]}"
link_opts[:class] = "#{'token ' unless opts[:inside_token_editor]}#{opts[:type]}"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually find the current way a little easier to read

link_opts = {}
link_opts.merge!({:target => "_blank"}) if opts[:inside_token_editor] || opts[:inside_linker_browse]
popover_url = url_for :controller => :resolver, :action => :resolve_readonly
popover_url += "?uri=#{opts[:uri]}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we aren't using a popover any more, the URL variable should probably change name.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agred, I had been thinking about that too

@anarchivist anarchivist left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rw+c from @awilfox's comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants