Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added sr_class instance var for bootstrap compatibility #160

Open
wants to merge 2 commits into
base: 7.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions seeker/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def __init__(self, field, label=None, sort=None, value_format=None, template=Non
self.export = export
self.highlight = highlight
self.field_definition = field_definition
self.sr_class = 'sr-only'

Choose a reason for hiding this comment

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

sr-only is for Bootstrap 4. visually-hidden is for Bootstrap 5.

https://getbootstrap.com/docs/5.3/migration/#:~:text=_visually%2Dhidden.scss-,Renamed%20.sr%2Donly,-and%20.sr%2Donly

That said, I'm not sure how seeker should handle Bootstrap constructs. Bootstrap is not a dependency, though we do link to a Bootstrap 3 CDN in the seeker.html template.


def __str__(self):
return self.label
Expand Down Expand Up @@ -114,7 +115,7 @@ def header(self):
else:
q['s'] = self.field
next_sort = 'descending' if sort == 'Ascending' else 'ascending'
sr_label = format_html(' <span class="sr-only">({})</span>', sort) if sort else ''
sr_label = format_html(f' <span class="{self.sr_class}">({sort})</span>') if sort else ''
if self.field_definition:
data_attributes_html = ' '.join(f'data-{name}="{value}"' for name, value in self.view.field_definition_data_attrs.items())
span = format_html('<span {} title="{{}}" class="fa fa-question-circle"></span>'.format(data_attributes_html), self.field_definition)
Expand Down Expand Up @@ -1194,7 +1195,7 @@ def header(self, results=None):
data_sort = self.field

next_sort = 'descending' if sort == 'Ascending' else 'ascending'
sr_label = format_html(' <span class="sr-only">({})</span>', sort) if sort else ''
sr_label = format_html(f' <span class="{self.sr_class}">({sort})</span>') if sort else ''

# If results provided, we check to see if header has space to allow for wordwrapping. If it already wordwrapped
# (i.e. has <br> in header) we skip it.
Expand Down