Skip to content
This repository was archived by the owner on Aug 7, 2020. It is now read-only.

Conversation

@cbourgois
Copy link
Contributor

@cbourgois cbourgois commented Apr 8, 2019

feat(oui-popover): add open, on-open and on-close bindings

Description of the Change

  • allow to control popover open state with open attribute
  • add on-open and on-close triggers

ceaa68d — feat(oui-popover): add open, on-open and on-close bindings

/cc @jleveugle @marie-j @AxelPeter

@cbourgois cbourgois self-assigned this Apr 8, 2019
@cbourgois cbourgois force-pushed the feat/popover-open branch from 15ee0be to 71f7e9a Compare April 8, 2019 14:53
@ovh-ux ovh-ux deleted a comment from ovh-cds Apr 8, 2019
@cbourgois cbourgois force-pushed the feat/popover-open branch from 71f7e9a to a4e8613 Compare April 8, 2019 15:57
@ovh-ux ovh-ux deleted a comment from ovh-cds Apr 8, 2019
@cbourgois cbourgois requested review from jleveugle and marie-j and removed request for euhmeuh April 9, 2019 03:51
* allow to control popover open state with `open` attribute
* add `on-open` and `on-close` triggers
@cbourgois cbourgois force-pushed the feat/popover-open branch from a4e8613 to ceaa68d Compare April 9, 2019 08:36

```html:preview
<div class="oui-doc-preview-only">
<p><strong>onOpen counter:</strong> {{$ctrl.numOpen }}</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<p><strong>onClose counter:</strong> {{$ctrl.numClose }}</p>
<p><strong>onClose counter:</strong> {{$ctrl.numClose}}</p>

$postLink () {
this.setPopover();
this.setTrigger();
this.setPopover()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.setPopover()
return this.setPopover()

}

$onChanges (changes) {
if (angular.isDefined(changes.open) && this.triggerElement) {
Copy link
Contributor

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 ?

Suggested change
if (angular.isDefined(changes.open) && this.triggerElement) {
if (changes.open != null && this.triggerElement) {

or

Suggested change
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)) {
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same story

@AxelPeter AxelPeter merged commit dac5381 into develop Apr 9, 2019
@AxelPeter AxelPeter deleted the feat/popover-open branch April 9, 2019 11:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Development

Successfully merging this pull request may close these issues.

5 participants