Open dpinho17 opened 9 years ago
I have not heard back from this issue yet, I do have a pull request with my fix. Please let me know if there are any issues with it.
Hi David,
I'm also having problems with cell's in edit mode and using enter to navigate to the next cell. When going to the next cell needs grid scrolling the editmode is ended.
The scrollBegin event handler within beginEditAfterScroll method is responsible for this: https://github.com/angular-ui/ui-grid/blob/cf8cd2f780f5e891603e5f6c90922e05d3973e8b/src/features/edit/js/gridEdit.js#L807
I did try your changes in the 3.1.1 version but it doesn't prevent the endEdit being called.
Hi, After trying to create our grid using the Edit With Cell Nav feature which is exactly what we need. We noticed that if you move up to something that is new in the viewport it does not correctly scroll which causes that Cell to not be in Edit Mode. This seemed to work fine for going below the bottom bound however going over the top bound did not work. After looking at the UI-Grid code I found the issue.
Reproductions Steps: http://ui-grid.info/docs/#/tutorial/309_editable_with_cellnav
If you scroll down to bottom in the demo app and then select a cell it will go to edit mode. Now continue to press the up key until you go past the top bound, in the old non fixed code it would incorrectly take you out of edit mode because of the scroll issue.
My Solution to the Problem: The issue lies within the scrollToIfNecessary method. The calculation for scrolling up is not exactly correct. There were a few minor issues making the scrolling not consistent and one major issue which caused the up scrolling not to work.
The main issue was that the variable pixelsToSeeRow was calculated assuming you always needed an extra row. Here is the line of code.
As you can see it adds one row to the seekRowIndex. This works perfectly fine when going down as you always move to the next row however for going up this should not include the +1 and should simply be:
Doing this fixes the major issue however there was also a few small calculation errors in the scrollLength and topBound variables.
For the scrollLength it is missing the scrollBarHeight which is included in other calculations for scrollLength throughout the code. Here is the before and after:
Code before scrollLength fix:
Code after scrollLength fix:
This fix allows the scrollToIfNecessary method to more accurately scroll to where it needs to scroll.
The last change was in TopBound. In the code the TopBound calculation includes HeaderHeight however from my testing it doesn't seem like headerheight should be included as this throws off the topBound which makes the scrollToIfNecessary scroll prematurely. Here is the before and after:
Code before topBound fix:
Code after topBound fix:
Those three fixes make the up movement fluent and continue to keep the cell edited when moving up. I have tried updating to 3.0.6 however the problem persists there. Below is the beginning of the old scrollToIfNecessary method and the same code with my fix so you can see all my changes. I also created a fork with the exact changes I made #4414.
Beginning of scrollToIfNecessary without my fix.
Beginning of scrollToIfNecessary with my fix.
If there are any questions please feel free to contact me, I have some issues with adding a new row at the bottom and scrolling to it but I will post that in a different issue thread.
Thanks, David Pinho david.pinho@optum.com