-
Notifications
You must be signed in to change notification settings - Fork 160
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(link-with-icon): refactor LINK_SIZE enum #11071
fix(link-with-icon): refactor LINK_SIZE enum #11071
Conversation
Deploy preview created for package Built with commit: 10794959219464696a2847ca1b62cef65d2370d5 |
Deploy preview created for package Built with commit: 10794959219464696a2847ca1b62cef65d2370d5 |
Deploy preview created for package Built with commit: 10794959219464696a2847ca1b62cef65d2370d5 |
Deploy preview created for package Built with commit: 10794959219464696a2847ca1b62cef65d2370d5 |
Deploy preview created for package Built with commit: 10794959219464696a2847ca1b62cef65d2370d5 |
@@ -50,7 +50,7 @@ class DDSLinkWithIcon extends StableSelectorMixin(BXLink) { | |||
* @internal | |||
*/ | |||
@property() | |||
size = LINK_SIZE.LARGE; | |||
size = 'lg' as LINK_SIZE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, having to cast this string seems like a smell. Does the solution from https://dev.to/ivanzm123/dont-use-enums-in-typescript-they-are-very-dangerous-57bh obviate the need for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to this method.
I had originally gone with the union instead to avoid having to import both an object and a type, but it seems that the type cascades through the inheritance chain on its own just fine, and if the object keeps the same name as the enum, we can make future refactors simpler.
[`Small size (sm)`]: 'sm', | ||
[`Large size (lg)`]: 'lg', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given #11071 (comment), what do you think about reverting this?
@@ -190,7 +182,7 @@ class BXLink extends FocusMixin(LitElement) { | |||
* Link size. | |||
*/ | |||
@property({ reflect: true }) | |||
size = LINK_SIZE.REGULAR; | |||
size: LINK_SIZE_TYPE = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question here – can you go back to setting this to LINK_SIZE.REGULAR
?
- @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected]
5443497
to
af5f295
Compare
This reverts commit af5f295.
) * fix(link-with-icon): refactor LINK_SIZE enum * fix(link-with-icon): export LINK_SIZE * fix(link-with-icon): change union to object-to-type * fix(link-with-icon): revert LINK_SIZE reference removals * chore(release): publish - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] * Revert "chore(release): publish" This reverts commit af5f295. --------- Co-authored-by: ibmdotcom-bot <[email protected]>
) * fix(link-with-icon): refactor LINK_SIZE enum * fix(link-with-icon): export LINK_SIZE * fix(link-with-icon): change union to object-to-type * fix(link-with-icon): revert LINK_SIZE reference removals * chore(release): publish - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] - @carbon/[email protected] * Revert "chore(release): publish" This reverts commit af5f295. --------- Co-authored-by: ibmdotcom-bot <[email protected]>
Related Ticket(s)
ADCMS-3542
Description
We've been digging into a sticky bug that we think we finally have an explanation for. To see the problem in action see this codepen.
As we understand it, this issue is:
There are lots of other places in the code base that we use ENUMs that don’t cause issues, but this one does and as far as we can tell it’s the only one that:
Changelog
Changed
LINK_SIZE
from enum to a union