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

NbRangePicker error with date-fns #1251

Closed
1 task
jmpmscorp opened this issue Feb 20, 2019 · 1 comment · Fixed by #1291
Closed
1 task

NbRangePicker error with date-fns #1251

jmpmscorp opened this issue Feb 20, 2019 · 1 comment · Fixed by #1291

Comments

@jmpmscorp
Copy link

Issue type

I'm submitting a ... (check one with "x")

  • [ x] bug report
  • feature request

Issue description

Current behavior:
NbRangePicker doesn't work when date-fns (@nebular/date-fns module) is used. However, if NbRangePicker is used without any external date library, it works well.

Expected behavior:
NbRangePicker works as expected using date-fns.

Steps to reproduce:
When first date is selected, this error is shown:

core.js:15714 ERROR RangeError: Invalid time value
    at format (index.js:388)
    at NbDateFnsDateService.push../node_modules/@nebular/date-fns/services/date-fns-date.service.js.NbDateFnsDateService.format (date-fns-date.service.js:50)
    at NbRangeAdapterService.push../node_modules/@nebular/theme/components/datepicker/datepicker-adapter.js.NbRangeAdapterService.format (datepicker-adapter.js:76)
    at NbDatepickerDirective.push../node_modules/@nebular/theme/components/datepicker/datepicker.directive.js.NbDatepickerDirective.writeInput (datepicker.directive.js:345)
    at SafeSubscriber._next (datepicker.directive.js:333)
    at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:207)
    at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (Subscriber.js:145)
    at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (Subscriber.js:80)
    at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:55)
    at TakeWhileSubscriber.push../node_modules/rxjs/_esm5/internal/operators/takeWhile.js.TakeWhileSubscriber.nextOrComplete (takeWhile.js:39)

Related code:

// ngx-admin theme.module.ts
@NgModule({
  imports: [
    ...BASE_MODULES, 
    ...NB_MODULES, 
    NbDateFnsDateModule.forRoot({
      parseOptions: { locale: es },
      formatOptions: { locale: es },
    }),
  ],
  exports: [...BASE_MODULES, ...NB_MODULES, ...COMPONENTS, ...PIPES],
  declarations: [...COMPONENTS, ...PIPES],
  entryComponents: [...ENTRY_COMPONENTS],
})
<!--custom.component.html-->
<nb-card size="medium">
  <nb-card-body>
        <input nbInput [nbDatepicker]="rangepicker">
        <nb-rangepicker #rangepicker format="dd/MM/yyyy"></nb-rangepicker>     
  </nb-card-body>
</nb-card>

Other information:

npm, node, OS, Browser
node: 8.15.0
npm: 6.4.1
OS: Windows 10
Browser: Chrome

Angular, Nebular

"@angular/animations": "~7.2.0",
    "@angular/cdk": "~7.2.0",
    "@angular/common": "~7.2.0",
    "@angular/compiler": "~7.2.0",
    "@angular/core": "~7.2.0",
    "@angular/forms": "~7.2.0",
    "@angular/http": "~7.2.0",
    "@angular/platform-browser": "~7.2.0",
    "@angular/platform-browser-dynamic": "~7.2.0",
    "@angular/router": "~7.2.0",
    "@auth0/angular-jwt": "^2.1.0",
    "@nebular/bootstrap": "^3.3.0",
    "@nebular/date-fns": "^3.3.0",
    "@nebular/security": "^3.3.0",
    "@nebular/theme": "^3.0.0",
@yggg
Copy link
Contributor

yggg commented Mar 11, 2019

Thanks for reporting @jmpmscorp!
Fixed in #1291.
For the time being, you can downgrade to date-fns@2.0.0-alpha.25, then it should work without problems.

By the way, all Nebular packages should be the same version to work properly. From issue description, I can see you use @nebular/theme version 3.0.0 and other @nebular/ packages are @3.3.0.

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

Successfully merging a pull request may close this issue.

3 participants