Skip to content
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

ngCellHasFocus assumes outermost editableCellTemplate element is the input element #436

Closed
barries opened this issue May 18, 2013 · 5 comments

Comments

@barries
Copy link

barries commented May 18, 2013

ngCellHasFocus assumes outermost editableCellTemplate element is the input element, which causes breakage when trying to wrap the input in a span (whether for style/layout purposes or to use ng-switch to vary the type of input based on the model). Here's the line that embodies the assumption:

var inputElement = angular.element(elementWithoutComments[0].children[0]); 
@spaceribs
Copy link

+1

@swalters
Copy link
Contributor

I'd like to see the Input elements disconnected from the ngCellHasFocus directive using messages. In ngCellHasFocus directive:

                $scope.$broadcast('startEdit');

                $scope.$on('endEdit', function() {
                    $scope.isFocused = false;
                    domUtilityService.digest($scope);
                });

all this code would be removed:

                ////Remove html comments for IE8
                //var elementWithoutComments = angular.element(elm[0].children).filter(function () {
                //    return this.nodeType !== 8;
                //});

                //var inputElement = angular.element(elementWithoutComments[0].children[0]);

                //if (inputElement.length > 0) {
                //    angular.element(inputElement).focus();
                //    $scope.domAccessProvider.selectInputElement(inputElement[0]);
                //    angular.element(inputElement).bind('blur', function () {
                //        $scope.isFocused = false;
                //        domUtilityService.digest($scope);
                //        return true;
                //    });
                //}

In ngInput directive:

               scope.$on('startEdit', function () {
                    elm.focus();
                });

                angular.element(elm).bind('blur', function () {
                    scope.$emit('endEdit');
                });

I tested this against the latest and it works well. Now I can wrap my input elements in divs/spans, whatever and control exactly what element's blur triggers the end edit.

What do you guys think?

@jonricaurte
Copy link
Contributor

Sounds good to me. I'll test it out when I get home.

jonricaurte added a commit that referenced this issue Jun 27, 2013
@jonricaurte
Copy link
Contributor

the events are now ngGridEventStartCellEdit and ngGridEventEndCellEdit

@jonricaurte jonricaurte mentioned this issue Jun 27, 2013
@sonicparke
Copy link
Contributor

Shouldn't this be working in 2.0.7? I've got ngGridEventEndCellEdit working but ngGridEventStartCellEdit doesn't seem to be working.

Plunker: http://plnkr.co/edit/JKZsmx?p=preview

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

5 participants