vuetify icon indicating copy to clipboard operation
vuetify copied to clipboard

[Bug Report] VSelect reports error on console when selecting items with return key

Open klaro00 opened this issue 7 years ago • 3 comments

Versions and Environment

Vuetify: 1.4.2 Vue: 2.5.22 Browsers: Chrome 71.0.3578.98 OS: Windows 10

Steps to reproduce

  1. Open Codepen link.
  2. Open browser console to observe console logs.
  3. Click the select box, choose an item using arrow keys, and select an item by hitting the return key.
  4. This error is reported in the console log: "Cannot use 'in' operator to search for 'button' in undefined".
  5. Optional: Change the Codepen: Replace "@blur.tab=..." by "@blur=..." (remove the "tab" modifier) and repeat selection of an item using return key. No error will be reported.

Expected Behavior

No error on console.

Actual Behavior

Error on console.

Reproduction Link

https://codepen.io/klaro00/pen/ebbYBd

Other comments

The source of the behaviour is the Return Key Handler "onEnterDown()". This handler calls the Blur Handlers without an argument (!). One of the Blur Handlers expects an argument (an event). This is only the case if you added a key modifier to the blur callback ("@blur.tab=...).

The errornous code fragment is shown below.

Suggested solution: The code of the second Blur Handler should first test for an existing argument.

on: {     
    ...
    ...
    blur: [
        function($event) {
            _vm.onBlur($event)        
        },       
        function($event) {          
            // Before:
            if (!("button" in $event) && _vm._k($event.keyCode, "tab", 9, $event.key, "Tab")) { return null }
            // After:
            if ($event && !("button" in $event) && _vm._k($event.keyCode, "tab", 9, $event.key, "Tab")) { return null }
            ...
            ...
        }      
    ]    
},

klaro00 avatar Jan 15 '19 18:01 klaro00

For future triage, this bug exists in 1.3.x as well.

johnleider avatar Jan 16 '19 01:01 johnleider

naive fix would be to add the argument to onEnterDown, but then blur would be emitted twice, once with the wrong event. The real question here is why onEnterDown exists and what the comment on line 579 means (// This should do something different)

relevant commit seems to be 5022b80c3397d8a64cbacdfff1fbe2bbf2770798

KaelWD avatar Jan 29 '19 07:01 KaelWD

Suggested solution: The code of the second Blur Handler should first test for an existing argument.

Those handlers are generated by vue, not vuetify. This was fixed at some point anyway, vselect no longer calls onBlur when enter is pressed.

KaelWD avatar Aug 01 '20 06:08 KaelWD