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

fix(files): Move aria-label for favorite icon from span to icon #41953

Merged
merged 2 commits into from
Dec 1, 2023

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Dec 1, 2023

Summary

Move the label from the span to the icon itself

Checklist

@susnux
Copy link
Contributor Author

susnux commented Dec 1, 2023

/backport to stable28

@susnux susnux requested review from ShGKme and artonge December 1, 2023 13:18
@susnux susnux force-pushed the fix/files-favorite-icon-label branch from c6bce33 to 164fe37 Compare December 1, 2023 21:00
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@susnux susnux force-pushed the fix/files-favorite-icon-label branch from 164fe37 to 22b1c86 Compare December 1, 2023 21:03
@susnux susnux merged commit 516fd73 into master Dec 1, 2023
42 checks passed
@susnux susnux deleted the fix/files-favorite-icon-label branch December 1, 2023 23:17
@susnux
Copy link
Contributor Author

susnux commented Dec 2, 2023

/backport f79a1ad to stable28

@@ -52,10 +55,14 @@ export default {
await this.$nextTick()
// MDI default viewbox is "0 0 24 24" but we add a stroke of 10px so we must adjust it
const el = this.$el.querySelector('svg')
el.setAttribute('viewBox', '-4 -4 30 30')
el?.setAttribute?.('viewBox', '-4 -4 30 30')
Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, why add optional chaining here? Is it possible that there would be no SVG, or that the SVG element would not have the setAttribute method?

Copy link
Contributor Author

@susnux susnux Dec 3, 2023

Choose a reason for hiding this comment

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

querySelector returns Element | undefined so for defensive programming either check and throw an error or use optional chaining. Otherwise at least casting to SvgElement is required.

But doing non of those results in type errors.

Copy link
Contributor

Choose a reason for hiding this comment

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

querySelector returns Element | undefined

But we select an SVG element here, and we at least know that there is the setAttribute method. No chance el.setAttribute would be undefined. If that was only for TypeScript, IMO, we should use !. or as to fix TS error. (Otherwise, there is an unneeded check in a bundle and runtime).

In theory querySelector could return undefined here, but it would mean that something has changed in <NcIconSvgWrapper> and ?. would hide the issue instead of exposing it.

@blizzz blizzz mentioned this pull request Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants