Opened 10 years ago

Closed 10 years ago

#9029 closed bug (fixed)

Autocomplete: Multiple demo has errors

Reported by: deap82 Owned by:
Priority: minor Milestone: 1.10.1
Component: ui.autocomplete Version: 1.10.0
Keywords: Cc:
Blocked by: Blocking:

Description

There is an error when trying to tab away from a multiple autocomplete decorated textbox, the bug exists in this demo: http://jqueryui.com/autocomplete/#multiple

Replicate error by typing "ja" in the textbox and then press tab.

The error message is: Uncaught TypeError: Cannot read property 'menu' of undefined

which is caused by the fact that $(this).data("autocomplete") is undefined.

The error resides in the demo codes keydown handler, I have replaced that code with the following:

      	if (event.keyCode === $.ui.keyCode.TAB &&
		$('.ui-autocomplete.ui-menu a.ui-state-focus:visible').length > 0) {
      		event.preventDefault();
      	}

The result is that the default action of pressing tab only will be prevented when an item is actually selected in the suggestion list. This works in my case when I have only one autocomplete textbox within the page. A more general solution is probably needed.

Change History (4)

comment:1 Changed 10 years ago by tj.vantoll

Resolution: duplicate
Status: newclosed

Duplicate of #8992.

comment:2 Changed 10 years ago by Scott González

Resolution: duplicate
Status: closedreopened

comment:3 Changed 10 years ago by Scott González

Milestone: none1.10.1
Status: reopenedopen
Summary: Tab error in the autocomplete multiple demoAutocomplete: Multiple demo has errors

comment:4 Changed 10 years ago by Scott González

Resolution: fixed
Status: openclosed

Autocomplete: Fix .data() references in demos. Fixes #9029 - Autocomplete: Multiple demo has errors.

Changeset: ceebe07e2c99190030c16b031813ae660d9283d1

Note: See TracTickets for help on using tickets.