Skip to content

Commit

Permalink
Fixed #4423
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed Nov 19, 2017
1 parent 9a0e724 commit 510e1f3
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/app/components/colorpicker/colorpicker.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {NgModule,Component,ElementRef,Input,Output,AfterViewChecked,OnDestroy,EventEmitter,forwardRef,Renderer2,ViewChild,ChangeDetectorRef} from '@angular/core';
import {trigger,state,style,transition,animate} from '@angular/animations';
import {CommonModule} from '@angular/common';
import {DomHandler} from '../dom/domhandler';
import {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';
import { NgModule, Component, ElementRef, Input, Output, AfterViewInit, AfterViewChecked, OnDestroy, EventEmitter, forwardRef, Renderer2, ViewChild, ChangeDetectorRef } from '@angular/core';
import { trigger, state, style, transition, animate } from '@angular/animations';
import { CommonModule } from '@angular/common';
import { DomHandler } from '../dom/domhandler';
import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';

export const COLORPICKER_VALUE_ACCESSOR: any = {
provide: NG_VALUE_ACCESSOR,
Expand Down Expand Up @@ -46,7 +46,7 @@ export const COLORPICKER_VALUE_ACCESSOR: any = {
],
providers: [DomHandler,COLORPICKER_VALUE_ACCESSOR]
})
export class ColorPicker implements ControlValueAccessor, AfterViewChecked, OnDestroy{
export class ColorPicker implements ControlValueAccessor, AfterViewInit, AfterViewChecked, OnDestroy{

@Input() style: any;

Expand Down Expand Up @@ -108,6 +108,15 @@ export class ColorPicker implements ControlValueAccessor, AfterViewChecked, OnDe

constructor(public el: ElementRef, public domHandler: DomHandler, public renderer: Renderer2, public cd: ChangeDetectorRef) {}

ngAfterViewInit() {
if (this.appendTo) {
if (this.appendTo === 'body')
document.body.appendChild(this.panelViewChild.nativeElement);
else
this.domHandler.appendChild(this.panelViewChild.nativeElement, this.appendTo);
}
}

ngAfterViewChecked() {
if(this.shown) {
this.onShow();
Expand Down Expand Up @@ -483,6 +492,10 @@ export class ColorPicker implements ControlValueAccessor, AfterViewChecked, OnDe

ngOnDestroy() {
this.unbindDocumentClickListener();

if (this.appendTo) {
this.el.nativeElement.appendChild(this.panelViewChild.nativeElement);
}
}
}

Expand Down

1 comment on commit 510e1f3

@jayakumar-ilink
Copy link

Choose a reason for hiding this comment

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

Which primeNg version, can i get this issue fix? Currently am having stable version of "primeng": "^4.1.2"

Please sign in to comment.