Skip to content

fix(datepicker): keep comp configuration updated (#5383) #5612

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

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

Conversation

treeskar
Copy link
Contributor

@treeskar treeskar commented Jan 22, 2020

In this PR I made component's configuration to be always up to date.

Overview

Datepicker configuration composed with 4 parts:

  1. _config: BsDatepickerConfig - default configuration
  2. Input bsConfig: Partial - user can pass partial configuration, that can overwrite default one
  3. Input bsValue: Date - datepicker value and also is part of config (config.value)
  4. all other inputs, like: isDisabled, minDate, maxDate... - component's configuration properties, that user can tune separately.

We have to keep in mind, that any value that comes from Input can be changed any time.

Why issue happened

Configuration was recalculated (setConfig) only on ngOnInit() and on show() calls, therefore there are situations when calculated config was out of sync with updated input config properties.

Solution

I created config$ stream, that listens to every part of component's configuration and recalculates final config if any part updated . This way "_config" always reflects actual configuration state.

  • read and followed the CONTRIBUTING.md guide.
  • built and tested the changes locally.
  • added/updated tests.
  • added/updated API documentation.
  • added/updated demos.

@codecov
Copy link

codecov bot commented Jan 22, 2020

Codecov Report

Merging #5612 into development will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##           development    #5612   +/-   ##
============================================
  Coverage        52.52%   52.52%           
============================================
  Files                3        3           
  Lines               99       99           
  Branches            17       17           
============================================
  Hits                52       52           
  Misses              37       37           
  Partials            10       10

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf0f78e...5ae88a7. Read the comment docs.

@treeskar treeskar force-pushed the fix-datepicker-date-format branch 9 times, most recently from d294de9 to 5ae88a7 Compare January 24, 2020 20:08
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.

2 participants