Skip to content

Commit

Permalink
fix(popover, tooltip): convert falsy values for adjustments to noop (#…
Browse files Browse the repository at this point in the history
…1905)

* fix(popover): convert falsy values for adjustments to noop

* fix(tooltip): convert falsy values for adjustments to noop

* fix: add missing imports
  • Loading branch information
yggg committed Oct 10, 2019
1 parent 04d7e33 commit 3ec69e7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
22 changes: 17 additions & 5 deletions src/framework/theme/components/popover/popover.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ import { Subject } from 'rxjs';
*
* By default popover will try to adjust itself to maximally fit viewport
* and provide the best user experience. It will try to change position of the popover container.
* If you wanna disable this behaviour just set it falsy value.
* If you want to disable this behaviour set it `noop`.
*
* ```html
* <button nbPopover="Hello, Popover!" [nbPopoverAdjustment]="false"></button>
* <button nbPopover="Hello, Popover!" nbPopoverAdjustment="noop"></button>
* ```
*
* Popover has a number of triggers which provides an ability to show and hide the component in different ways:
Expand Down Expand Up @@ -143,11 +143,23 @@ export class NbPopoverDirective implements NbDynamicOverlayController, OnChanges

/**
* Container position will be changes automatically based on this strategy if container can't fit view port.
* Set this property to any falsy value if you want to disable automatically adjustment.
* Available values: clockwise, counterclockwise.
* Set this property to `noop` value if you want to disable automatically adjustment.
* Available values: `clockwise` (default), `counterclockwise`, `vertical`, `horizontal`, `noop`.
* */
@Input('nbPopoverAdjustment')
adjustment: NbAdjustment = NbAdjustment.CLOCKWISE;
get adjustment(): NbAdjustment {
return this._adjustment;
}
set adjustment(value: NbAdjustment) {
if (!value) {
// @breaking-change Remove @5.0.0
console.warn(`Falsy values for 'nbPopoverAdjustment' are deprecated and will be removed in Nebular 5.
Use 'noop' instead.`);
value = NbAdjustment.NOOP;
}
this._adjustment = value;
}
protected _adjustment: NbAdjustment = NbAdjustment.CLOCKWISE;

/**
* Describes when the container will be shown.
Expand Down
20 changes: 16 additions & 4 deletions src/framework/theme/components/tooltip/tooltip.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,24 @@ export class NbTooltipDirective implements OnInit, OnChanges, AfterViewInit, OnD
@Input('nbTooltipPlacement')
position: NbPosition = NbPosition.TOP;
/**
* Container position will be changes automatically based on this strategy if container can't fit view port.
* Set this property to any falsy value if you want to disable automatically adjustment.
* Available values: clockwise, counterclockwise.
* Container position will change automatically based on this strategy if container can't fit view port.
* Set this property to `noop` value if you want to disable automatic adjustment.
* Available values: `clockwise` (default), `counterclockwise`, `vertical`, `horizontal`, `noop`.
*/
@Input('nbTooltipAdjustment')
adjustment: NbAdjustment = NbAdjustment.CLOCKWISE;
get adjustment(): NbAdjustment {
return this._adjustment;
}
set adjustment(value: NbAdjustment) {
if (!value) {
// @breaking-change Remove @5.0.0
console.warn(`Falsy values for 'nbPopoverAdjustment' are deprecated and will be removed in Nebular 5.
Use 'noop' instead.`);
value = NbAdjustment.NOOP;
}
this._adjustment = value;
}
protected _adjustment: NbAdjustment = NbAdjustment.CLOCKWISE;

@Input('nbTooltipClass')
tooltipClass: string = '';
Expand Down

0 comments on commit 3ec69e7

Please sign in to comment.