vue-material icon indicating copy to clipboard operation
vue-material copied to clipboard

MdSelect "TypeError: Cannot read property 'badInput' of undefined"

Open cvalues opened this issue 4 years ago • 21 comments

This error occurs when an option is selected in the select:

Browser: Firefox & Chrome

https://stackoverflow.com/questions/63994411/vue-js-error-in-nexttick-typeerror-cannot-read-property-badinput-of-undef

cvalues avatar Oct 28 '20 07:10 cvalues

https://github.com/vuematerial/vue-material/issues/2270

seems like the same error

cvalues avatar Oct 28 '20 08:10 cvalues

same error here...

mullerivan avatar Nov 04 '20 03:11 mullerivan

same error ... Kazam_screenshot_00101

stephsalou avatar Nov 05 '20 10:11 stephsalou

Hi, I have created a pull-request for this one now. PR #2287

@marqbeniamin could you review it?

johnkristijan avatar Nov 06 '20 09:11 johnkristijan

Yep same error, please merge if all good.

DevVue avatar Nov 10 '20 09:11 DevVue

Also getting this error as of today!

DJDeWitt avatar Nov 10 '20 18:11 DJDeWitt

Hi, I have created a pull-request for this one now. PR #2287

@marqbeniamin could you review it?

While your PR fixes possible data integrity errors, it has been merged into the dev branch in another PR (#2262). The change made there does not offer a solution to the root problem though:

When a value is selected in MdSelect it tries to get the DOM elements ($el) validy property. While this works for MdInput, which has an <input> element as its root DOM element; MdSelects $el is an <md-menu> which doesn't have the validity property.

A solution for this would be to add a reference to the correct <select> element. I created a PR to fix the original intended behavior and provide a fix for this issue: #2288

hansvn avatar Nov 12 '20 21:11 hansvn

Can you update this to npm package?

leonardoks16 avatar Dec 05 '20 04:12 leonardoks16

I did overwrite the ...\node_modules\vue-material\ with current github dev branch but i still get

  [10364:1210/183001.221:INFO:CONSOLE(629)] "[Vue warn]: Error in nextTick: "TypeError: Cannot read property 'badInput' of undefined"

  found in

  ---> <MdSelect> at src/components/MdField/MdSelect/MdSelect.vue
         <MdField> at src/components/MdField/MdField.vue
           <MdCardContent> at src/components/MdCard/MdCardContent/MdCardContent.vue
             <MdCard> at src/components/MdCard/MdCard.vue
               <Klient> at src/renderer/components/KlientDetail.vue
                 <Baf> at src/renderer/App.vue
                   <Root>", source: webpack-internal:///./node_modules/vue/dist/vue.esm.js (629)
  [10364:1210/183001.221:INFO:CONSOLE(1896)] "TypeError: Cannot read property 'badInput' of undefined", source: webpack-internal:///./node_modules/vue/dist/vue.esm.js (1896)

when I select option. Is there a way to bypass this? As this is crippling for any development.

EDIT: I also tried npm install https://github.com/vuematerial/vue-material/ and still same error...

jkalousek avatar Dec 10 '20 17:12 jkalousek

I did overwrite the ...\node_modules\vue-material\ with current github dev branch

Hey, I was losing my mind over this. Have you tried going to node_modules\vue-material\dist\vue-material.js and changing the code there? Search for isInvalidValue and replace the body with return this.$el.validity ? this.$el.validity.badInput : false;

I'm not sure if this is the right way to fix the bug, but it works.

bart-src avatar Dec 19 '20 10:12 bart-src

I did overwrite the ...\node_modules\vue-material\ with current github dev branch

Hey, I was losing my mind over this. Have you tried going to node_modules\vue-material\dist\vue-material.js and changing the code there? Search for isInvalidValue and replace the body with return this.$el.validity ? this.$el.validity.badInput : false;

I'm not sure if this is the right way to fix the bug, but it works.

Yep, I did end up figuring this out as well. But this "fix" cames from #2287 and @hansvn noted few posts above about this PR following: "The change made there does not offer a solution to the root problem" so I see this as woraround but not a fix.

jkalousek avatar Dec 20 '20 10:12 jkalousek

will this bug be fixed any time soon? seems this is happening even in the simplest case, where fixed values are bound, it even happens on the vue-material documentation page

killer-it44 avatar Jan 17 '21 07:01 killer-it44

@xiaoye999 looks like we need to fix it on our own

SanujBansal avatar Jan 17 '21 08:01 SanujBansal

@SanujBansal , how soon can that be fixed?

It's affecting apps on production

OladetounJed avatar Jan 19 '21 13:01 OladetounJed

I decided just to hide the WARN. This is how you can do it:

// main.js
import Vue from 'vue';

Vue.config.errorHandler = (err, vm, info) => {
  if (process.env.NODE_ENV !== 'production') {
    // Show any error but this one
    if (err.message !== "Cannot read property 'badInput' of undefined") {
      console.error(err);
    }
  }
};

new Vue({
  el: '#app',
  render: (h) => h(App),
  router,
});

farena avatar Jan 28 '21 15:01 farena

Is good that their slogan is "Build well-crafted apps with Material Design and Vue 2.0" but every singe component is buggy AF xD maybe leave it at "Build well-crafted apps with Vue 2.0" that at least works

buzzingcookie avatar Feb 01 '21 22:02 buzzingcookie

Hi, do you any update about this bug? I just finished configuring my whole project with vuematerial :( and I found our about this.

SalvoLunar avatar Feb 05 '21 16:02 SalvoLunar

Is good that their slogan is "Build well-crafted apps with Material Design and Vue 2.0" but every singe component is buggy AF xD maybe leave it at "Build well-crafted apps with Vue 2.0" that at least works

@buzzingcookie

Instead of being a toxic human being you could have just push a pull request with a fix. It seems that you are the godfather of developing - should be easy for you huh?

This ist an open source project so nobody is restricted to just wait that something happen - learn open source or close your mouth and move on ty.

lyssar avatar Mar 02 '21 19:03 lyssar

Hello, is this resolved, the commit about it doesn't include any file, I'm on beta 15 and I still get this error, thanks ? (I did the solution explained by bart-src on Dec 19, 2020 and it work like a charme... but, would be good to have it in the package)

RobinLeblond avatar Mar 24 '21 19:03 RobinLeblond

The merged fix back in Feb looks good on the surface but I don't believe gets to the root of the problem. While troubleshooting I noticed that certain components that use mdField will have the parent container of the input element in this.$el and NOT the actual input element (mdSelect being an example). I resolved the issue and kept the desired behavior by doing the following instead:

return this.$el.validity ? this.$el.validity.badInput : this.$el.querySelector("input").validity.badInput;

The error was legitimate and I believe the current merged solution will end up masking broken functionality. I haven't yet tested this fix across all Form element types but so far fixes the error w/ mdSelect.

PR: https://github.com/vuematerial/vue-material/pull/2323

derekmwright avatar Apr 09 '21 12:04 derekmwright

i can not wait the new patch. Therefore:

import { MdField } from 'vue-material/dist/components'

Vue.use(MdField)

Vue.component('MdSelect', Vue.options.components.MdSelect.extend({
    methods: {
        isInvalidValue: function isInvalidValue () {
            return this.$el.validity ? this.$el.validity.badInput : this.$el.querySelector('input').validity.badInput
        }
    }
}))

danilovmy avatar Mar 04 '22 18:03 danilovmy