mirror of
https://github.com/discourse/discourse.git
synced 2026-08-07 13:19:19 +08:00
We've been improperly adding category and tag descriptions to the title attribute of category and tag links. This removes them. [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/title) summarizes the problem with title attributes used as supplemental information: > Use of the title attribute is highly problematic for: > > People using touch-only devices > People navigating with keyboards > People navigating with assistive technology such as screen readers or magnifiers > People experiencing fine motor control impairment > People with cognitive concerns > > This is due to inconsistent browser support, compounded by the additional assistive technology parsing of the browser-rendered page. If a tooltip effect is desired, it is better to [use a more accessible technique](https://inclusive-components.design/tooltips-toggletips/) that can be accessed with the above browsing methods. The most immediate issue is that the title descriptions can be very long for screenreaders and can make navigating the page fairly verbose. What someone using JAWS comes across every time they tab through this category: <img width="450" alt="image" src="https://github.com/user-attachments/assets/2277df83-4cad-4f86-8c86-147c0458bd26" /> We already have this information available in the "about this category" topic, in category dropdowns, category headings (when visible) and other places, so it's not critical to have here. There's also a general asymmetry: * mouse users: can optionally see them on hover * keyboard users: can never access them * touch users: can never access them * screenreaders: some read them so they have to be skipped every time If we find these sort of tooltips valuable and want to add a description on hover, we should do it in a way that's reachable to hover/keyboard/touch without adding verbosity to typical nav for screenreaders.
80 lines
2.6 KiB
Ruby
Vendored
80 lines
2.6 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
describe "Viewing sidebar as anonymous user" do
|
|
let(:sidebar) { PageObjects::Components::NavigationMenu::Sidebar.new }
|
|
|
|
describe "when viewing the tags section" do
|
|
fab!(:tag1) do
|
|
Fabricate(:tag, name: "tag 1", description: "tag 1 description <script>").tap do |tag|
|
|
Fabricate.times(1, :topic, tags: [tag])
|
|
end
|
|
end
|
|
|
|
fab!(:tag2) do
|
|
Fabricate(:tag, name: "tag 2").tap { |tag| Fabricate.times(2, :topic, tags: [tag]) }
|
|
end
|
|
|
|
fab!(:tag3) do
|
|
Fabricate(:tag, name: "tag 3", description: "tag 3 description").tap do |tag|
|
|
Fabricate.times(3, :topic, tags: [tag])
|
|
end
|
|
end
|
|
|
|
fab!(:tag4) do
|
|
Fabricate(:tag, name: "tag 4").tap { |tag| Fabricate.times(2, :topic, tags: [tag]) }
|
|
end
|
|
|
|
fab!(:tag5) do
|
|
Fabricate(:tag, name: "tag 5").tap { |tag| Fabricate.times(2, :topic, tags: [tag]) }
|
|
end
|
|
|
|
fab!(:tag6) do
|
|
Fabricate(:tag, name: "tag 6").tap { |tag| Fabricate.times(1, :topic, tags: [tag]) }
|
|
end
|
|
|
|
it "should not display the tags section when tagging has been disabled" do
|
|
SiteSetting.tagging_enabled = false
|
|
|
|
visit("/latest")
|
|
|
|
expect(sidebar).to have_no_tags_section
|
|
end
|
|
|
|
it "should not display the tags section when site has no top tags and `default_navigation_menu_tags` site setting has not been set" do
|
|
Tag.delete_all
|
|
|
|
visit("/latest")
|
|
|
|
expect(sidebar).to have_no_tags_section
|
|
end
|
|
|
|
it "should display the site's top tags when `default_navigation_menu_tags` site setting has not been set" do
|
|
visit("/latest")
|
|
|
|
expect(sidebar).to have_tags_section
|
|
expect(sidebar).to have_all_tags_section_link
|
|
expect(sidebar).to have_tag_section_links([tag3, tag2, tag4, tag5, tag1])
|
|
end
|
|
|
|
it "should display the site's top tags when `default_navigation_menu_tags` site setting has been set but the tags configured are hidden to the user" do
|
|
SiteSetting.default_navigation_menu_tags = "#{tag5.name}"
|
|
Fabricate(:tag_group, permissions: { "staff" => 1 }, tag_names: [tag5.name])
|
|
|
|
visit("/latest")
|
|
|
|
expect(sidebar).to have_tags_section
|
|
expect(sidebar).to have_all_tags_section_link
|
|
expect(sidebar).to have_tag_section_links([tag3, tag2, tag4, tag1, tag6])
|
|
end
|
|
|
|
it "should display the tags configured in `default_navigation_menu_tags` site setting when it has been set" do
|
|
SiteSetting.default_navigation_menu_tags = "#{tag3.name}|#{tag4.name}"
|
|
|
|
visit("/latest")
|
|
|
|
expect(sidebar).to have_tags_section
|
|
expect(sidebar).to have_all_tags_section_link
|
|
expect(sidebar).to have_tag_section_links([tag3, tag4])
|
|
end
|
|
end
|
|
end
|