Skip to content

Conversation

nickvergessen
Copy link
Contributor

No description provided.

@@ -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
Copy link
Contributor Author

@nickvergessen nickvergessen Mar 8, 2022

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
Copy link
Contributor Author

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>

@@ -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
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regression #2547

Copy link
Contributor

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()

Copy link
Contributor Author

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 🤷‍♂️

Copy link
Contributor

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>
@nickvergessen nickvergessen force-pushed the bugfix/noid/fix-error-spam-from-buttons branch from d3e9dc8 to b170766 Compare March 8, 2022 13:47
@nickvergessen nickvergessen added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Mar 8, 2022
@nickvergessen nickvergessen added this to the 5.1.1 milestone Mar 8, 2022
@marcoambrosini marcoambrosini merged commit 0908824 into master Mar 9, 2022
@marcoambrosini marcoambrosini deleted the bugfix/noid/fix-error-spam-from-buttons branch March 9, 2022 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish bug Something isn't working feature: button
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants