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

feat(annotate_citations): use aria-attributes #4932

Merged
merged 4 commits into from
Jan 22, 2025

Conversation

grossir
Copy link
Contributor

@grossir grossir commented Jan 15, 2025

Solves #1178

Use aria-description on the anchor tag for a resolved citation. The description uses the case name, truncated if it is too long

@grossir grossir self-assigned this Jan 15, 2025
cl/citations/tests.py Outdated Show resolved Hide resolved
Copy link
Member

@mlissner mlissner left a comment

Choose a reason for hiding this comment

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

Nice. Seems easy enough!

Did you see we have a function called best_case_name or get_best_case_name or similar? It might be a useful tool in this.

Why do you need it to support dockets and opinions/clusters?

Solves #1178

Use aria-description on the anchor tag for a resolved citation. The description uses the case name, truncated if it is too long
@grossir grossir force-pushed the 1178-aria-attributes-for-citations branch from 454457a to da7cd1f Compare January 16, 2025 16:37
@grossir grossir marked this pull request as ready for review January 16, 2025 16:39
@grossir grossir requested a review from mlissner January 16, 2025 16:48
@grossir
Copy link
Contributor Author

grossir commented Jan 16, 2025

Why do you need it to support dockets and opinions/clusters?

From looking at get_and_clean_opinion_text I thought it would apply to RecapDocuments; but I see that it doesn't

def get_and_clean_opinion_text(document: Opinion | RECAPDocument) -> None:

Copy link
Member

@mlissner mlissner left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me, but I don't know much about aria and I don't know this code super well. Onwards for a more careful review. Thanks Gianfranco!

@mlissner mlissner assigned flooie and unassigned grossir Jan 17, 2025
@mlissner
Copy link
Member

Process-wise, I assigned this to you, Bill, for triage or to review, as you see fit. Gianfranco, I removed you as assignee, so that it will show up in Bill's sprint view. Bill, if you're not going to review you should assign it to somebody else AND make them reviewer.

@@ -61,8 +63,12 @@ def generate_annotations(
"</span>",
]
else: # If successfully matched...
case_name = trunc(best_case_name(opinion.cluster), 60, "...")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why TRUNCate this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean I understand why we do it with the metadata field but an aria attribute is for accessibility and that user may want the full name that is being linked no? for the description we are already on the page ...

Copy link
Contributor Author

@grossir grossir Jan 17, 2025

Choose a reason for hiding this comment

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

Why TRUNCate this?

In case it's too long; since we expect the aria-* to be useful specially for "Id", "Supra", "Ibid" where there is no further textual reference; but could be too repetitive, worst in case of long case names.

Should I remove this? I am not sure about the statistics on case name lenght

I mean I understand why we do it with the metadata field but an aria attribute is for accessibility and that user may want the full name that is being linked no? for the description we are already on the page ...

The targeted case is a screen reader. Setting aria-description makes both the attribute value and the link content be read. You can check a longer comment about that here

@flooie

@grossir grossir removed their assignment Jan 17, 2025
@mlissner
Copy link
Member

Sorry, random thought: Do we need to worry about special characters in the aria-attribute and encode them?

@flooie
Copy link
Contributor

flooie commented Jan 17, 2025

@mlissner I would think so. but how many random characters do you expect in our name strings? Are you worried about characters messing up readers or messing up the HTML

@mlissner
Copy link
Member

@flooie, yes, I'm worried about a case with a name like, "A&M Univesity v. Foo" that would mess up our HTML.

Copy link
Contributor

@flooie flooie left a comment

Choose a reason for hiding this comment

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

Thanks @grossir

@flooie flooie enabled auto-merge January 22, 2025 20:34
@flooie flooie merged commit a2ce5ea into main Jan 22, 2025
15 checks passed
@flooie flooie deleted the 1178-aria-attributes-for-citations branch January 22, 2025 20:44
@mlissner
Copy link
Member

@flooie, @grossir, did we resolve this?

I'm worried about a case with a name like, "A&M Univesity v. Foo" that would mess up our HTML.

@flooie
Copy link
Contributor

flooie commented Jan 22, 2025

no - apologies

@flooie flooie restored the 1178-aria-attributes-for-citations branch January 22, 2025 21:10
@flooie
Copy link
Contributor

flooie commented Jan 22, 2025

@mlissner - in my limited testing - ampersands do not cause an issue with the HTML.

@mlissner
Copy link
Member

What's your testing, because I don't think you can put am ampersand into an HTML attribute without it being invalid. It's possible that it renders correctly, but that'd just be the browser fixing your error, and it's probably possible for worse errors to cause real problems (like what if there's a double quote in the case name, for example).

@mlissner
Copy link
Member

This says in html5 ampersands are kind of OK, but mostly not: https://stackoverflow.com/a/19442133/64911. But other characters like double quotes will definitely cause issues.

@flooie
Copy link
Contributor

flooie commented Jan 23, 2025

I tested the ampersand and saw no issue extracting it back out - but Im sure you are right about quotes being an issue - ill make the change to escape theHTML

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants