Skip to content

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
@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
@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

// 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

Development

Successfully merging this pull request may close these issues.

[BITV] 9.4.1.2/3.3 - In the table, in the "Name" column, there are elements that have been marked as favorites with a star icon. (2)

4 participants