Edit Feature with Cellnav not consistent on last row when hiding horizontal scrollbar
We detected this issue with @andresbiso and @zargoht
Plunker: http://plnkr.co/edit/n2Lf5A4yOBbzCXzkm6fp
It's a basic UI Grid with ui-grid-edit and ui-grid-cellNav features
<div ui-grid="gridOptions" ui-grid-edit ui-grid-cellNav class="grid"></div>
and the horizontal scrollbar hidden.
$scope.gridOptions.enableHorizontalScrollbar = uiGridConstants.scrollbars.NEVER;
Steps to reproduce
- Scroll down to the last row of the grid
- Single-click the Name cell of the last row ("Marci Emerson" on the example)
- Press a character key
It should replace the cell's content with the character inputed as happens with the other rows. Instead of this, it opens the editing field with the previous value loaded and with the input cursor at the end. So pressing new characters will append them at the end of the existing text instead of replacing it.
Note: this behaviour isn't consistent. Sometimes it behaves as expected and sometimes the issue happens. You have to repeat the steps 2 and 3, eventually it will happen.
Same problem here. Maybe i found the reason in the "s.debounce" function. In version 3.1.0 the timeout will be created like "timeout = $timeout(later, wait);" In the newer versions: "timeout = $timeout(later, wait,false);"
When i delete the third parameter of then angular timeout function (invokeApply) everything works like before.
Thanks @JZehet for the answer!
Here is how I use it (this way you don't have to change the ui-grid source code);
- Create a ui-grid-general-decorator.js
'use strict';
angular
.module('app.core')
.config(uiGridGeneralConfig);
uiGridGeneralConfig.$inject = ['$provide'];
function uiGridGeneralConfig($provide) {
$provide.decorator('gridUtil', extendGridUtil);
}
extendGridUtil.$inject = ['$delegate', '$timeout'];
function extendGridUtil($delegate, $timeout) {
wrap and overwrite gridUtil object methods
jshint ignorestart
var debounce;
debounce = $delegate.debounce;
jshint ignoreend
$delegate.debounce = function (func, wait, immediate) {
var timeout, args, context, result;
function debounce() {
jshint validthistrue
context = this;
args = arguments;
var later = function () {
timeout = null;
if (!immediate) {
result = func.apply(context, args);
}
};
var callNow = immediate && !timeout;
if (timeout) {
$timeout.cancel(timeout);
}
timeout = $timeout(later, wait);
if (callNow) {
result = func.apply(context, args);
}
return result;
}
debounce.cancel = function () {
$timeout.cancel(timeout);
timeout = null;
};
return debounce;
};
return $delegate;
}
- Remember to include it in your index.html
<script><src=app/core/core-decorators/ui-grid-general-decorator.js><script>
You are right. I don't want to change the source code. But i think it is a ui-grid BUG. Different edit behavior on a cell by changing a scrollbar setting !!!?. Can not be.
Maybe i use your solution. Many thanks.
Thanks for contributing! This repository has been transferred, and we're preparing the new 5.x release. We're closing older issues and pull requests as part of the reset. Please join us on Discord to follow the work or continue the conversation: https://discord.gg/Baz4w8ZWN