-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
properly attach blur/focus listeners on fab-action-items.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,25 +33,27 @@ | |
if (children.attr('ng-repeat')) { | ||
children.addClass('md-fab-action-item'); | ||
} else { | ||
// After setting up the listeners, wrap every child in a new div and add a class that we can | ||
// scale/fling independently | ||
// Wrap every child in a new div and add a class that we can scale/fling independently | ||
children.wrap('<div class="md-fab-action-item">'); | ||
} | ||
}, | ||
|
||
link: function(scope, element, attributes, controllers) { | ||
// Grab whichever parent controller is used | ||
var controller = controllers[0] || controllers[1]; | ||
|
||
// Make the children open/close their parent directive | ||
if (controller) { | ||
angular.forEach(element.children(), function(child) { | ||
angular.element(child).on('focus', controller.open); | ||
angular.element(child).on('blur', controller.close); | ||
}); | ||
|
||
return function postLink(scope, element, attributes, controllers) { | ||
// Grab whichever parent controller is used | ||
var controller = controllers[0] || controllers[1]; | ||
|
||
// Make the children open/close their parent directive | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
topherfangio
Contributor
|
||
if (controller) { | ||
angular.forEach(element.children(), function(child) { | ||
// Attach listeners to the `md-fab-action-item` | ||
This comment has been minimized.
Sorry, something went wrong.
topherfangio
Contributor
|
||
child = angular.element(child).children()[0]; | ||
|
||
angular.element(child).on('focus', controller.open); | ||
angular.element(child).on('blur', controller.close); | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
})(); | ||
})(); |
Why should children open/close parent directive? Isnt only md-fab-trigger supposed to do this?
I believe this is different behavior from what I saw in Google Inbox and child elements opening parent results in worse UX and less flexibility. If someone wants something like this it would be easy enough for him just to use the "md-open" attribute.