Skip to content
This repository has been archived by the owner on Jul 13, 2020. It is now read-only.

Fix error when navigating past end of tags #23

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

isaacws
Copy link

@isaacws isaacws commented Jul 2, 2014

When using the arrow key to select tags, if you arrow past the last or
first tag a javascript error occurs "Uncaught TypeError: Cannot read
property 'target' of undefined "

When using the arrow key to select tags, if you arrow past the last or
first tag a javascript error occurs "Uncaught TypeError: Cannot read
property 'target' of undefined "
@jgable
Copy link

jgable commented Jul 2, 2014

Looks good to me 👍 . I mean, I'd prefer to just check at the top for no ev and return early with this.elements.input.focus() or something if possible.

What do you think @dansnetwork ?

Return right away if ev is null
@isaacws
Copy link
Author

isaacws commented Jul 2, 2014

I just changed my repo to return early and skip the focus. It changes the behavior to stop and the end tags instead of turning to a cursor. Not sure which behavior is desired.

@@ -460,6 +460,8 @@
},

_focus : function(ev) {
if(!ev)
Copy link

Choose a reason for hiding this comment

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

The indentation here is all wacky. And please always use { .. } with if statements.

Copy link

Choose a reason for hiding this comment

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

Also, before the return, you should do this.elements.input.focus(); like the original code path did.

@dansnetwork
Copy link
Contributor

The desired behavior is that it returns focus to the <input>.

@isaacws
Copy link
Author

isaacws commented Jul 2, 2014

If we just wish to focus why do we even need these lines?

$closest = $(ev.target).closest('li'),
$data = $closest.data('ui-inputosaurus') || $closest.data('inputosaurus');
if(!ev || !$data){

Instead

_focus : function(ev) {
    var widget = (ev && ev.data.widget) || this;
    widget.elements.input.focus();
},

As for the indentation, my editor is set to use spaces instead of tabs. I'll update my source

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants