Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Fixed ExtractToVariable Menu Close Issue due to scrolling #14492

Merged
merged 5 commits into from
Aug 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,19 @@ define(function(require, exports, module) {
inlineMenu = new InlineMenu(session.editor, Strings.EXTRACTTO_VARIABLE_SELECT_EXPRESSION);

inlineMenu.onHover(function (expnId) {
// Remove the scroll Handlers If already Attached.
editor.off("scroll.inlinemenu");
// Add a scroll handler If Selection Range is not View.
// This is Added for a Bug, where Menu used not to open for the first Time
if(!editor.isLineVisible(editor.posFromIndex(expns[expnId].end).line)) {
editor.on("scroll.inlinemenu", function() {
// Remove the Handlers so that If scroll event is triggerd again by any other operation
// Menu should not be reopened.
// Menu Should be reopened only if Scroll event is triggered by onHover.
editor.off("scroll.inlinemenu");
inlineMenu.openRemovedMenu();
});
}
editor.setSelection(editor.posFromIndex(expns[expnId].start), editor.posFromIndex(expns[expnId].end));
});

Expand Down
13 changes: 13 additions & 0 deletions src/widgets/InlineMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,19 @@ define(function (require, exports, module) {
}
};

/**
* Displays the last menu which was closed due to Scrolling
*/
InlineMenu.prototype.openRemovedMenu = function () {
if (this.opened === true) {
if (this.$menu && !this.$menu.hasClass("open")) {
var menuPos = this._calcMenuLocation();
this.$menu.addClass("open")
.css({"left": menuPos.left, "top": menuPos.top, "width": menuPos.width + "px"});
}
}
};

/**
* Closes the menu
*/
Expand Down