Skip to content

Commit

Permalink
hide date picker if field is disabled or readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
darkv committed Jun 28, 2016
1 parent fb64e2a commit c0bd26a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxDatePicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,19 @@ private Boolean showYearControls() {
* @return JavaScript for onFocus binding of HTML input
*/
public String onFocusScript() {
if (booleanValueForBinding("readonly", false) || booleanValueForBinding("disabled", false)) {
return null;
}
return showCalendarScript();
}

/**
* @return JavaScript for onClick binding of HTML input
*/
public String onClickScript() {
if (booleanValueForBinding("readonly", false) || booleanValueForBinding("disabled", false)) {
return null;
}
StringBuilder script = new StringBuilder(200);
script.append("event.cancelBubble=true; ");
script.append(showCalendarScript());
Expand Down

4 comments on commit c0bd26a

@spelletier
Copy link
Member

Choose a reason for hiding this comment

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

I always set the date field to readonly to user cannot enter invalid dates using keyboard... Now, they won't even be able to enter dates with the calendar. I support the new behaviour for the disabled binding though.

Unless someone has a better solution, please restore the picker for readonly field.

@spelletier
Copy link
Member

Choose a reason for hiding this comment

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

I tested some cases and there is a difference between setting the readonly binding and adding the attribute using otherTagString = "readonly".

When setting the readonly binding, the value is not processed anyway but with otherTagString, it is and I used the otherTagString way so your commit does not break my apps. I do not understand where the difference come from though.

My memory was not precise enough...

@darkv
Copy link
Member Author

@darkv darkv commented on c0bd26a Jun 29, 2016

Choose a reason for hiding this comment

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

For your use case I would suggest to make a new boolean binding like manualInput so the intended behavior is clear. Using the readonly binding to achieve that seems wrong.

@darkv
Copy link
Member Author

@darkv darkv commented on c0bd26a Jun 29, 2016

Choose a reason for hiding this comment

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

I added that feature in 6bc5a92

Please sign in to comment.