Skip to content

Commit

Permalink
feat: removed config 'disableOnNilValue' in favour of default behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
florianjung79 committed May 18, 2021
1 parent 8c14a5e commit 8bfd4b6
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 10 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ visible = new EventEmitter<boolean>();
### Global Config
- You can pass any `tippy` option at global config level.
- `beforeRender` - Hook that'll be called before rendering the tooltip content ( applies only for string )
- `disableOnNilValue` - Boolean flag that disables the tooltip if the assigned value is null or undefined. This can be seen as a shortcut to `isEnable`

### Create `tippy` Programmatically

Expand Down
9 changes: 3 additions & 6 deletions projects/ngneat/helipopper/src/lib/tippy.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class TippyDirective implements OnChanges, AfterViewInit, OnDestroy, OnIn
}

private createInstanceOnNonNilValue() {
if (this.globalConfig.disableOnNilValue && this.content !== null && this.content !== undefined) {
if (this.content !== null && this.content !== undefined) {
this.createInstance();
}
}
Expand All @@ -208,10 +208,7 @@ export class TippyDirective implements OnChanges, AfterViewInit, OnDestroy, OnIn
this.globalConfig.onCreate?.(instance);
},
onShow: instance => {
this.zone.run(() => {
this.instance.setContent(this.resolveContent());
});

this.zone.run(() => this.instance.setContent(this.resolveContent()));
if (this.useHostWidth) {
instance.popper.style.width = this.hostWidth;
instance.popper.style.maxWidth = this.hostWidth;
Expand All @@ -234,7 +231,7 @@ export class TippyDirective implements OnChanges, AfterViewInit, OnDestroy, OnIn
}

private resolveContent() {
if (this.globalConfig.disableOnNilValue && (this.content === null || this.content === undefined)) {
if (this.content === null || this.content === undefined) {
return null;
}

Expand Down
1 change: 0 additions & 1 deletion projects/ngneat/helipopper/src/lib/tippy.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export interface TippyConfig extends TippyProps {
variations: Record<string, Partial<TippyProps>>;
defaultVariation: keyof TippyConfig["variations"];
beforeRender?: (text: string) => string;
disableOnNilValue?: boolean;
}

export function coerceElement(element: TippyElement) {
Expand Down
3 changes: 1 addition & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ import { popperVariation, TippyModule, tooltipVariation, withContextMenuVariatio
...popperVariation,
theme: "light-border"
}
},
disableOnNilValue: true
}
})
],
providers: [],
Expand Down

0 comments on commit 8bfd4b6

Please sign in to comment.