Skip to content

Empty header cell: race condition in Firefox using autoresize and custom header cell by template url #4851

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

Closed
Maus3rVonDutch opened this issue Dec 14, 2015 · 0 comments

Comments

@Maus3rVonDutch
Copy link

Hi, there seems to be a race condition going on when using custom header templates (fetched by url and NOT defined as inline html templates) in combination with the autoresize directive. This only happens in Firefox, the problem does not occur in IE-9/11 or Chrome. The result is an empty header cell.

The problem occurs because the autoresize directive triggers a refresh of the grid, by calling startTimeout(), when the custom templates not have been loaded yet (i.e. the template promises have not been resolved). The refresh in turn executes the uiGridHeaderCell directive, resulting in an empty $scope.col.headerCellTemplate.

I do have a workaround for the problem, but this is probably not the best solution:

module.directive('uiGridAutoResize', ['$timeout', 'gridUtil', function ($timeout, gridUtil) {
    return {
      require: 'uiGrid',
      scope: false,
      link: function ($scope, $elm, $attrs, uiGridCtrl) {
         var prevGridWidth, prevGridHeight;
         var isInitialized = false;

         ...

         // instead of calling startTimeout directly, wait until the grid rows are rendered for the first time

          uiGridCtrl.grid.api.core.on.rowsRendered($scope, function () {
              if (!isInitialized) {
                  isInitialized = true;
                  startTimeout();
              }
          });


       $scope.$on('$destroy', function() {
          clearTimeout(resizeTimeoutId);
        });
      ...
falsyvalues added a commit to falsyvalues/ui-grid that referenced this issue Oct 11, 2017
…r-cell`, `filter`.

Fixes issues angular-ui#4744, angular-ui#5717, angular-ui#5115, angular-ui#5196, angular-ui#5712, angular-ui#5260, angular-ui#5196, angular-ui#4851, angular-ui#4514, angular-ui#5601

For URL-based templates we need to be sure that content arrived before `$compile` and `$elm.append` call.
mportuga pushed a commit that referenced this issue Oct 31, 2017
…r-cell`, `filter`.

Fixes issues #4744, #5717, #5115, #5196, #5712, #5260, #5196, #4851, #4514, #5601

For URL-based templates we need to be sure that content arrived before `$compile` and `$elm.append` call.
vishalnarewade pushed a commit to vishalnarewade/ui-grid that referenced this issue Nov 6, 2017
…r-cell`, `filter`.

Fixes issues angular-ui#4744, angular-ui#5717, angular-ui#5115, angular-ui#5196, angular-ui#5712, angular-ui#5260, angular-ui#5196, angular-ui#4851, angular-ui#4514, angular-ui#5601

For URL-based templates we need to be sure that content arrived before `$compile` and `$elm.append` call.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants