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

Commit

Permalink
Fixed ExtractToVariable Menu Close Issue due to scrolling (#14492)
Browse files Browse the repository at this point in the history
* Fixed ExtractToVariable Menu Close Issue due to scrolling

* Addressed Review Comments

* Addessed review comments

* Addressed Review Comments

* Addressed Review Comments
  • Loading branch information
niteskum authored and boopeshmahendran committed Aug 2, 2018
1 parent afcbff0 commit 0cee7d4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/extensions/default/JavaScriptRefactoring/ExtractToVariable.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,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

0 comments on commit 0cee7d4

Please sign in to comment.