Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1085
Cancelling editCellEnding event loses cell focus
posted

When in cell edit mode, if we hook the editCellEnding event and cancel it due to invalid information and set the keepEditing flag to true, the invalid cell's contents can end up displayed over the top of the next cell if the user left the invalid cell by tabbing.

We have tracked this issue down to the premature removal of the edit class in infragistics.ui.grid.updating.js, method _endEdit.

In this method, the editingCell css is removed as soon as the validators are checked, but this action does not take into account the fact the the editCellEnding event may be cancelled.

The solution is to only remove the class after editCellEnding has successfully completed:

                    // cell editing
                    if (!vals) {
                        if (e && oldUpdate && !_filter(editor, 'validate')) {
                            if (!stop) {
                                _stop(stop = e);
                            }
                            // scroll to and set focus to editor
                            this._scrollTo(td, editor, 1);
                            return 1;
                        }
                        // Don't remove the class until we are sure editCellEnding succeeds
                        //td.removeClass(this.css.editingCell);
                    }
                    // prevent double processing of same event (user showed alert!)
                    this._skip = 1;
                    // 1-hide buttons
                    this._doButtons(1);
                    val = _filter(editor, 'getValue');
                    arg = this._evtArg(td, editor, val);
                    arg.update = !!update;
                    arg.oldValue = editor._oldCellVal;
                    if (!vals) {
                        arg.keepEditing = false;
                    }
                    if (!this._fire('editCellEnding', eArg, arg)) {
                        arg.value = editor._oldCellVal;
                    }
                    if (oldUpdate && !vals && e && arg.keepEditing) {
                        _stop(e);
                        // scroll to and set focus to editor
                        this._scrollTo(td, editor, 1);
                        delete this._skip;
                        return 1;
                    }
                    // Added next 3 to support cancellation and continued editing of cell when editCellEnding fails.
                    if (!vals) {
                        td.removeClass(this.css.editingCell);
                    }