Skip to content

Commit

Permalink
bugfix: scrolls to top of table on any key press if the top is not on…
Browse files Browse the repository at this point in the history
… the screen (#348)
  • Loading branch information
warpech committed Feb 25, 2013
1 parent f2b412f commit 290cde9
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 16 deletions.
2 changes: 1 addition & 1 deletion dist/jquery.handsontable.full.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Licensed under the MIT license.
* http://handsontable.com/
*
* Date: Mon Feb 25 2013 20:14:15 GMT+0100 (Central European Standard Time)
* Date: Mon Feb 25 2013 20:22:36 GMT+0100 (Central European Standard Time)
*/

.handsontable {
Expand Down
7 changes: 2 additions & 5 deletions dist/jquery.handsontable.full.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Licensed under the MIT license.
* http://handsontable.com/
*
* Date: Mon Feb 25 2013 20:14:15 GMT+0100 (Central European Standard Time)
* Date: Mon Feb 25 2013 20:22:36 GMT+0100 (Central European Standard Time)
*/
/*jslint white: true, browser: true, plusplus: true, indent: 4, maxerr: 50 */

Expand Down Expand Up @@ -2778,19 +2778,16 @@ HandsontableTextEditorClass.prototype.beginEditing = function (row, col, prop, u

this.instance.rootElement.append(this.TEXTAREA_PARENT);

this.refreshDimensions(row, col); //need it instantly, to prevent https://github.com/warpech/jquery-handsontable/issues/348
this.TEXTAREA[0].focus();
this.setCaretPosition(this.TEXTAREA[0], this.TEXTAREA[0].value.length);

if (this.instance.getSettings().asyncRendering) {
this.refreshDimensions(row, col); //need it instantly, to prevent https://github.com/warpech/jquery-handsontable/issues/348
var that = this;
setTimeout(function () {
that.refreshDimensions(row, col); //need it after rerender to reposition in case scroll was moved
}, 0);
}
else {
this.refreshDimensions(row, col);
}
}

HandsontableTextEditorClass.prototype.refreshDimensions = function (row, col) {
Expand Down
2 changes: 1 addition & 1 deletion jquery.handsontable.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Licensed under the MIT license.
* http://handsontable.com/
*
* Date: Mon Feb 25 2013 20:14:15 GMT+0100 (Central European Standard Time)
* Date: Mon Feb 25 2013 20:22:36 GMT+0100 (Central European Standard Time)
*/

.handsontable {
Expand Down
7 changes: 2 additions & 5 deletions jquery.handsontable.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Licensed under the MIT license.
* http://handsontable.com/
*
* Date: Mon Feb 25 2013 20:14:15 GMT+0100 (Central European Standard Time)
* Date: Mon Feb 25 2013 20:22:36 GMT+0100 (Central European Standard Time)
*/
/*jslint white: true, browser: true, plusplus: true, indent: 4, maxerr: 50 */

Expand Down Expand Up @@ -2778,19 +2778,16 @@ HandsontableTextEditorClass.prototype.beginEditing = function (row, col, prop, u

this.instance.rootElement.append(this.TEXTAREA_PARENT);

this.refreshDimensions(row, col); //need it instantly, to prevent https://github.com/warpech/jquery-handsontable/issues/348
this.TEXTAREA[0].focus();
this.setCaretPosition(this.TEXTAREA[0], this.TEXTAREA[0].value.length);

if (this.instance.getSettings().asyncRendering) {
this.refreshDimensions(row, col); //need it instantly, to prevent https://github.com/warpech/jquery-handsontable/issues/348
var that = this;
setTimeout(function () {
that.refreshDimensions(row, col); //need it after rerender to reposition in case scroll was moved
}, 0);
}
else {
this.refreshDimensions(row, col);
}
}

HandsontableTextEditorClass.prototype.refreshDimensions = function (row, col) {
Expand Down
5 changes: 1 addition & 4 deletions src/editors/textEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,16 @@ HandsontableTextEditorClass.prototype.beginEditing = function (row, col, prop, u

this.instance.rootElement.append(this.TEXTAREA_PARENT);

this.refreshDimensions(row, col); //need it instantly, to prevent https://github.com/warpech/jquery-handsontable/issues/348
this.TEXTAREA[0].focus();
this.setCaretPosition(this.TEXTAREA[0], this.TEXTAREA[0].value.length);

if (this.instance.getSettings().asyncRendering) {
this.refreshDimensions(row, col); //need it instantly, to prevent https://github.com/warpech/jquery-handsontable/issues/348
var that = this;
setTimeout(function () {
that.refreshDimensions(row, col); //need it after rerender to reposition in case scroll was moved
}, 0);
}
else {
this.refreshDimensions(row, col);
}
}

HandsontableTextEditorClass.prototype.refreshDimensions = function (row, col) {
Expand Down

0 comments on commit 290cde9

Please sign in to comment.