-
Notifications
You must be signed in to change notification settings - Fork 85
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 error spam from buttons #2540
Fix error spam from buttons #2540
Conversation
src/components/Button/Button.vue
Outdated
@@ -361,7 +361,7 @@ export default { | |||
|
|||
methods: { | |||
getText() { | |||
return this.$slots.default ? this.$slots.default[0].text.trim() : null | |||
return this.$slots.default && this.$slots.default[0] && this.$slots.default[0].text ? this.$slots.default[0].text.trim() : null |
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.
Before:
Error in beforeUpdate hook: "TypeError: this.$slots.default[0].text is undefined"
found in
---> <Button>
TypeError: this.$slots.default[0].text is undefined
getText Button.js:1
beforeUpdate Button.js:1
VueJS 6
invokeWithErrorHandling
callHook
before
flushSchedulerQueue
nextTick
flushCallbacks
*/ | ||
type: { | ||
type: String, | ||
validator(value) { | ||
return ['primary', 'tertiary', 'error', 'warning', 'success', ''].indexOf(value) !== -1 | ||
return ['primary', 'secondary', 'tertiary', 'error', 'warning', 'success', ''].indexOf(value) !== -1 |
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.
Before:
[Vue warn]: Invalid prop: custom validator check failed for prop "type".
found in
---> <Button> at src/components/Button/Button.vue
<LobbyStatus> at src/components/RightSidebar/LobbyStatus.vue
<AppSidebar> at src/components/AppSidebar/AppSidebar.vue
<RightSidebar> at src/components/RightSidebar/RightSidebar.vue
<Content> at src/components/Content/Content.vue
<App> at src/App.vue
<Root>
src/components/Button/Button.vue
Outdated
@@ -361,7 +361,7 @@ export default { | |||
|
|||
methods: { | |||
getText() { | |||
return this.$slots.default ? this.$slots.default[0].text.trim() : null | |||
return this.$slots.default && this.$slots.default[0] && this.$slots.default[0].text ? this.$slots.default[0].text.trim() : null |
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.
Probably better this.$slots?.default[0]?.text?
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.
Fixed
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.
Regression #2547
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.
@nickvergessen @JuliaKirschenheuter
I think the correct expression would be:
this.$slots?.default?.[0]?.text?.trim()
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.
That sadly didn't work 🤷♂️
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. Okay, but did you noticed the ?.
directly behind of default
? That wasn't included in the commit. Though it is needed when default
can be null/undefined.
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
d3e9dc8
to
b170766
Compare
No description provided.