Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(datepicker): fix config example #4620

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bastienmoulia
Copy link
Contributor

Fix #3848 and #3873 but maybe the documentation is OK and it's the NgbInputDatepickerConfig which do not works well.

Copy link
Member

@maxokorokov maxokorokov left a comment

Choose a reason for hiding this comment

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

I don't think the issue is with the demo. I don't think it should work this way, there should be only NgbInputDatepickerConfig.

  • input config extends normal config, so it has all the same stuff
  • we provide it here →
    { provide: NgbDatepickerConfig, useExisting: NgbInputDatepickerConfig },
  • only inputdatepikcer-specific inputs are initalized for some reason →
    @Input() autoClose = this._config.autoClose;
    these are not →
    @Input() minDate: NgbDateStruct;
  • when we open datepicker popup, we copy inputs here →
    private _applyDatepickerInputs(datepickerComponentRef: ComponentRef<NgbDatepicker>): void {
    [
    'contentTemplate',
    'dayTemplate',
    'dayTemplateData',
    'displayMonths',
    'firstDayOfWeek',
    'footerTemplate',
    'markDisabled',
    'minDate',
    'maxDate',
    'navigation',
    'outsideDays',
    'showNavigation',
    'showWeekNumbers',
    'weekdays',
    ].forEach((inputName: string) => {
    if (this[inputName] !== undefined) {
    datepickerComponentRef.setInput(inputName, this[inputName]);
    }
    });
    datepickerComponentRef.setInput('startDate', this.startDate || this._model);
    }

It all doesn't seem right... input config should NOT extend the normal one, if you have to inject both.

Maybe we just need to initialize ALL inputs with the config values? but then what's the reason for providing NgbDatepickerConfig... I can't see what's broken, need to write tests..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Global configuration of datepickers minDate and MaxDate example is misleading
2 participants