Skip to content

Expandable row scrolling jumps #2162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jon-armstrong-zz opened this issue Nov 20, 2014 · 19 comments
Open

Expandable row scrolling jumps #2162

jon-armstrong-zz opened this issue Nov 20, 2014 · 19 comments

Comments

@jon-armstrong-zz
Copy link

I have configured a grid with expandable rows, but my expandable row groups have a variable number of rows. Since the row height on the main grid is required to be a fixed value, I need the rows within the expandable row group to scroll so I can see the ones that don't fit in the viewport. Unfortunately, when I attempt to scroll within the row group, the scroll jumps around (tested in Mac Firefox and Chrome). It appears that the scroll listener from the main grid may be interfering. Basically, this happens whenever the height of the expandable rows exceeds the row height on the parent table.

Since it has been indicated elsewhere (#1887) that variable row height isn't something that will be implemented, which would be another solution to this issue, then being able to scroll properly within the expandable row group would be appreciated.

@PaulL1 PaulL1 added this to the 3.0 milestone Nov 21, 2014
@PaulL1
Copy link
Contributor

PaulL1 commented Nov 21, 2014

@jpuri: is this a problem in expandable do you think, or more to do with the new scroll behaviour @c0bra?

@jpuri
Copy link
Contributor

jpuri commented Nov 21, 2014

Hi @jon-armstrong ,
I am looking into the issue, but in the mean while can you also plz try this option: expandableRowHeight.

@jon-armstrong-zz
Copy link
Author

@jpuri, I am already setting expandableRowHeight. Otherwise, it looks like the code defaults to 150. Either way, the problem is the same. Thanks for looking into it.

@jpuri
Copy link
Contributor

jpuri commented Nov 21, 2014

Hi @jon-armstrong ,

I could replicate and check the scroll issue you are mentioning, but the way scrolling is currently implemented in grid, fixing this issue will be bigger task.

You can use the upward and downward arrows for scrolling, I checked they are working correctly.
Will that siffice for your requirement ?

@jon-armstrong-zz
Copy link
Author

@jpuri,

I did notice that the scrollbar controls still work, but that probably won't work for end users who will expect the scroll wheel to work the same as everywhere else. I'd still like to see this fixed, but have redesigned the data presentation into two tables instead of using expandable rows.

@jpuri
Copy link
Contributor

jpuri commented Nov 25, 2014

@jon-armstrong , I am looking at this issue, I will update you in 1-2 days.

@jpuri
Copy link
Contributor

jpuri commented Nov 25, 2014

Apparently the scroll event getting propagated to parent grid and its starts scrolling. Scroll event can not be cancelled nor can we stop its propagation.

The default behavior of browsers to not to scroll the parent until child is totally scrolled (is at topmost or bottommost position). But ui-grid is not using default scrolling provided by browsers, but has rather implemented its own (for performance reasons).

@c0bra , can you suggest something to fix this.

@devakone
Copy link

Experiencing the same issue.

@c0bra
Copy link
Contributor

c0bra commented Dec 2, 2014

All,

I don't have a solution off the top of my head. Obviously we need to somehow prevent the parent grid from receiving the bubbled-up scroll event. Are we sure can we not prevent propagation? The grid already doesn't seem to bubble the event up to the parent document and allow scroll events from inside the viewport to scroll the document.

@jpuri
Copy link
Contributor

jpuri commented Dec 2, 2014

Hey @c0bra, scroll is Non-Cancelable: https://developer.mozilla.org/en-US/docs/Web/Events/scroll

The way browsers implement scrolling is that parent element does not scroll until child is fully scrolled and reaches its top or bottom. But its tough for us to implement it in this way because for its Non-Cancelable nature.

@jpuri
Copy link
Contributor

jpuri commented Dec 3, 2014

We can probably check something like mousewheel event, I found this event fixing the issue to some extent.
But it is not a standard event and thus not dependable thing: https://developer.mozilla.org/en-US/docs/Web/Events/mousewheel

@cyates81
Copy link
Contributor

cyates81 commented Jan 8, 2015

I am experiencing the same issue. I would like for my expandable row to scroll when the content inside of it is too large to fit within expandableRowHeight. Setting overflow-y: scroll; doesn't work like it should because of this event propagation issue.

Anybody have any other ideas to get this to work? Thanks.

@ValentinH
Copy link

ValentinH commented Apr 16, 2015

I have noticed this problem in the Expendable tutorial. What is the status?

The strange thing is that the child scroll only works as expected if the parent is not scrolled at all.
Is it something that was already improved compared to the problem explained in this issue or that was already the behaviour at the time this issue has been filled?

@josephaanthony
Copy link

There is another issue with expandable. The expandable demo is broken too. When you do a expand all. The selection gets misalligned. The biggest problem is, if you scroll to the bottom, it even fails to render the last few rows and leaves a lot of empty spaces inside the grid. Any hint on what could be the issue. I am happy to fix the expandable grid

@tomerz012
Copy link

I had the same issue, I fixed it by setting the expandableRowHeight to high number (400)

@s4253
Copy link

s4253 commented Mar 30, 2017

Hello all, is this issue still not resolved ?
I observe similar issue with huge space at the end of the table if i scroll down table with one or two rows expanded. Is there any bug opened for it or maybe even close ?

@dwdbk
Copy link

dwdbk commented Jul 17, 2017

Hello everyone,
I had the same issue but i fixed it by setting the expandableRowHeight to => (number of lines to display +1 ) * rowHeight

@jcubic
Copy link

jcubic commented Jan 14, 2019

The problem is in scroll wheel this is workaround/hack:

/*
 * this file is fix for long standing bug in ui-grid
 * https://github.com/angular-ui/ui-grid/issues/2162
 */
(function () {
    'use strict';

    angular
        .module('divosUiApp.widget.grid')
        .directive('wheelFix', wheelFix);
    
    function wheelFix() {
      return {
        restrict: 'A',
        link: function link($scope, $element) {
          var $container = $element.find('.ui-grid-render-container');
          // wait for rendering of ui-grid
          if (!$container.length) {
            setTimeout(link.bind(this, $scope, $element), 400);
          }
          // code copied from $destroy in ui-grid source code
          ['wheel', 'mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'].forEach(function(event) {
            $container.off(event);
          });
        }
      }
    }
})();

and this directive to ui-grid element it will remove mousewheel handler, I don't think it's needed (the event).

<div wheel-fix ui-grid="gridOptions"></div>

I have same code (custom mousewheel) in my project jQuery Terminal that was started in 2011, I didn't removed that code from the library though. but user can disable it (by setting his own handler) and he can scroll the output of the terminal.

If you want to fix this bug, it's somewhere in mouse wheel logic ui-grid-render-container.js#L67 but I would just remove it, if it just scroll the view, unless it do some other logic.

@ghost
Copy link

ghost commented Jan 30, 2019

Tried it with ui-grid v 4.4.x, and it solves this problem.

Thank you jcubic!

The problem is in scroll wheel this is workaround/hack:

/*
 * this file is fix for long standing bug in ui-grid
 * https://github.com/angular-ui/ui-grid/issues/2162
 */
(function () {
    'use strict';

    angular
        .module('divosUiApp.widget.grid')
        .directive('wheelFix', wheelFix);
    
    function wheelFix() {
      return {
        restrict: 'A',
        link: function link($scope, $element) {
          var $container = $element.find('.ui-grid-render-container');
          // wait for rendering of ui-grid
          if (!$container.length) {
            setTimeout(link.bind(this, $scope, $element), 400);
          }
          // code copied from $destroy in ui-grid source code
          ['wheel', 'mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'].forEach(function(event) {
            $container.off(event);
          });
        }
      }
    }
})();

and this directive to ui-grid element it will remove mousewheel handler, I don't think it's needed (the event).

<div wheel-fix ui-grid="gridOptions"></div>

I have same code (custom mousewheel) in my project jQuery Terminal that was started in 2011, I didn't removed that code from the library though. but user can disable it (by setting his own handler) and he can scroll the output of the terminal.

If you want to fix this bug, it's somewhere in mouse wheel logic ui-grid-render-container.js#L67 but I would just remove it, if it just scroll the view, unless it do some other logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests