Commit 830e2582 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Avoid grid selection when opening new tab.

Instead of preventing the selection from happening at the first place,
which conflicted with drag-drop, allow the selection to happen, but
after the fact re-select the currently selected item.
parent 1549d694
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -80,12 +80,12 @@ Ext.define('Docs.controller.Classes', {
        this.control({
            'classtree': {
                classclick: function(cls, event) {
                    this.opensNewWindow(event) ? window.open("#/api/" + cls) : this.loadClass(cls);
                    this.handleClassClick(cls, event, this.getTree());
                }
            },
            'classgrid': {
                classclick: function(cls, event) {
                    this.opensNewWindow(event) ? window.open("#/api/" + cls) : this.loadClass(cls);
                    this.handleClassClick(cls, event, this.getFavoritesGrid());
                }
            },

@@ -120,6 +120,18 @@ Ext.define('Docs.controller.Classes', {
        });
    },

    // We don't want to select the class that was opened in another window,
    // so restore the previous selection.
    handleClassClick: function(cls, event, view) {
        if (this.opensNewWindow(event)) {
            window.open("#/api/" + cls);
            view.selectClass(this.currentCls ? this.currentCls.name : "");
        }
        else {
            this.loadClass(cls);
        }
    },

    // Code for the middle mouse button
    MIDDLE: 1,

+0 −10
Original line number Diff line number Diff line
@@ -69,16 +69,6 @@ Ext.define('Docs.view.ClassGrid', {

        this.callParent(arguments);

        // Prevent item from becoming selected right away, because the
        // the click event that follows can possibly cause the class
        // to be loaded in another window, in which case the selection
        // of the clicked-on item should not happen.  When it needs to
        // be selected, the #showClass method in Class controller will
        // explicitly call #selectClass.
        // this.on("beforeselect", function() {
        //     return false;
        // }, this);

        this.on("itemclick", function(view, record, item, index, event) {
            // Don't fire classclick when close button clicked
            if (!event.getTarget("img")) {
+3 −0
Original line number Diff line number Diff line
@@ -95,6 +95,9 @@ Ext.define('Docs.view.tree.Tree', {
                n.expand();
            });
        }
        else {
            this.getSelectionModel().deselectAll();
        }
    },

    /**