primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Calendar not honoring selectOtherMonths property correctly

Open hjalmers opened this issue 9 years ago • 2 comments

I'm submitting a ...

[x ] bug report

Current behavior Even when selectOtherMonths = false month is clickable (but not selectable) and the ui-state-disabled class is applied even if selectOtherMonths = true

Expected behavior selectOtherMonths = false should disable the ability to click on dates in other months and the class ui-state-disabled should only be applied when this property is false.

Minimal reproduction of the problem with instructions Use calendar and set selectOtherMonths to false

What is the motivation / use case for changing the behavior? The function should work as described

  • Angular version: 2.3.1

  • PrimeNG version: 1.1.2

  • Browser: all

hjalmers avatar Dec 27 '16 10:12 hjalmers

Create a pull request with a fix for this issue and also 1689 as they are related.

The first of my commits should be ignored as it was done against incorrect branch/fork.

hjalmers pull request is good and adds good functionality to allow specification of "disabled" dates, but I have created a pull request that fixes only the problem at hand, i.e. that selectOtherMonths option is not working properly - just to minimize the changes and potential impact.

Summary of the changes:

  • applied disabled CSS class for days in other months only if the above option is not set to "true"
  • year for dateMeta object is calculated properly now for next month (previously it was only working for previous months or for next months only in case if the year was also incremented)
  • made sure that "selectable" property of dateMeta is set correctly for dates in other month (i.e. set to false if selectOtherMonths is not set to "true" and set to true otherwise) - this is to make sure other month dates behaves the same as other ones - if they can be selected they act as enabled ones but if they cannot be selected they behave the same as disabled dates (i.e. when click on them calendar doesnt close down)

external-olgierd avatar Feb 27 '17 11:02 external-olgierd

I can't replicate with 4.0.RC1, anyone. selectOtherMonths is false by default. Note that, following enables it;

 selectOtherMonths="false"

should be;

 [selectOtherMonths]="false"

Or just leaving it as it is since it is false by default.

cagataycivici avatar Mar 27 '17 13:03 cagataycivici