Unplanned
Last Updated: 20 Jan 2021 13:45 by ADMIN
CaseNet
Created on: 20 Jan 2021 13:26
Category: Menu
Type: Bug Report
1
JavaScript error (Uncaught TypeError: Cannot read property 'keyCode' of undefined) is thrown when selecting an autocomplete suggestion in Chromium browsers

Reproduction - http://somup.com/crVYIDot19

Setup to reproduce:

<telerik:RadContextMenu ID="RadContextMenu1" runat="server">
    <Targets>
        <telerik:ContextMenuDocumentTarget />
    </Targets>
    <Items>
        <telerik:RadMenuItem Text="item">
            <ItemTemplate>
                <asp:TextBox ID="TextBox2" runat="server" />
            </ItemTemplate>
        </telerik:RadMenuItem>
    </Items>
</telerik:RadContextMenu>

<telerik:RadButton runat="server" ID="RadButton2" Text="Postback" AutoPostBack="true" />

Steps to reproduce:

  • Show the context menu with a right mouse click on the document.
  • Type in a custom value in the TextBox embedded in the menu.
  • Perform a postback by clicking on the RadButton.
  • Show the context menu again. In the textbox, pick the autocomplete suggestion by the browser.
1 comment
ADMIN
Doncho
Posted on: 20 Jan 2021 13:45

Hi,

Here is a temporary workaround for the issue:

Place the below JavaScript code on the page, after the ScriptManager (or RadScriptManager):

Telerik.Web.UI.RadContextMenu.prototype._onKeyDown = function (e) {

    if (!e.keyCode && !e.rawEvent) return;

    var item = this.get_focusedItem();
    var keyCode = e.keyCode ? e.keyCode : e.rawEvent.keyCode;
    var items = this.get_items();

    if ($(e.target).closest(".rmTemplate").length > 0) {
        return false;
    }

    if (keyCode === Sys.UI.Key.esc) {
        this._hide();
        return false;
    }

    if (!item) {
        switch (keyCode) {
            case Sys.UI.Key.up:
                var lastItem = items.getItem(items.get_count() - 1);

                if (lastItem.get_visible()) {
                    lastItem.focus(e);
                } else {
                    lastItem.focusPreviousItem(e);
                }
                break;

            case Sys.UI.Key.down:
                var firstItem = items.getItem(0);

                if (firstItem.get_visible()) {
                    firstItem.focus(e);
                } else {
                    firstItem.focusNextItem(e);
                }
                break;

            case Sys.UI.Key.enter:
                this._hide();
                break;
        }
        return false;
    }

    return this._keyboardNavigator._onKeyDown(e, item);
}
Kind regards,
Doncho
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.