-
Notifications
You must be signed in to change notification settings - Fork 7
feat(oui-popover): add open, on-open and on-close bindings #385
Conversation
15ee0be to
71f7e9a
Compare
71f7e9a to
a4e8613
Compare
* allow to control popover open state with `open` attribute * add `on-open` and `on-close` triggers
a4e8613 to
ceaa68d
Compare
|
|
||
| ```html:preview | ||
| <div class="oui-doc-preview-only"> | ||
| <p><strong>onOpen counter:</strong> {{$ctrl.numOpen }}</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <p><strong>onOpen counter:</strong> {{$ctrl.numOpen }}</p> | |
| <p><strong>onOpen counter:</strong> {{$ctrl.numOpen}}</p> |
| ```html:preview | ||
| <div class="oui-doc-preview-only"> | ||
| <p><strong>onOpen counter:</strong> {{$ctrl.numOpen }}</p> | ||
| <p><strong>onClose counter:</strong> {{$ctrl.numClose }}</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <p><strong>onClose counter:</strong> {{$ctrl.numClose }}</p> | |
| <p><strong>onClose counter:</strong> {{$ctrl.numClose}}</p> |
| $postLink () { | ||
| this.setPopover(); | ||
| this.setTrigger(); | ||
| this.setPopover() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| this.setPopover() | |
| return this.setPopover() |
| } | ||
|
|
||
| $onChanges (changes) { | ||
| if (angular.isDefined(changes.open) && this.triggerElement) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't you want to create code as much decoupled from Angular as possible ?
| if (angular.isDefined(changes.open) && this.triggerElement) { | |
| if (changes.open != null && this.triggerElement) { |
or
| if (angular.isDefined(changes.open) && this.triggerElement) { | |
| if (changes.open !== undefined && this.triggerElement) { |
if you are afraid of == :)
| .on("click", () => this.onTriggerClick()); | ||
| }); | ||
|
|
||
| if (angular.isUndefined(this.$attrs.ouiPopoverOpen)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same story
| this.$element.attr("aria-expanded", true); | ||
|
|
||
| // force the digest because the popover is outside the angular digest loop | ||
| this.$timeout(() => this.onOpen(), 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| this.$timeout(() => this.onOpen(), 0); | |
| this.$timeout(() => this.onOpen()); |
is enough, 0 is the default value for the second parameter :)
| this.$element.attr("aria-expanded", false); | ||
|
|
||
| // force the digest because the popover is outside the angular digest loop | ||
| this.$timeout(() => this.onClose(), 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same story
feat(oui-popover): add
open,on-openandon-closebindingsDescription of the Change
openattributeon-openandon-closetriggersceaa68d — feat(oui-popover): add open, on-open and on-close bindings
/cc @jleveugle @marie-j @AxelPeter