Skip to content

MaterialDatePicker only works correct with Editor Framework when it is attached to the View #740

@rwursthorn

Description

@rwursthorn

When you use a MaterialDatePicker in your view to store a Date-Value, but you don't show the DatePicker, it won't be attached to the view.
When you take a look at the code

    @Override
    public Date getValue() {
        return getPickerDate();
    }

    @Override
    public void setValue(Date value, boolean fireEvents) {
        if (value == null) {
            clear();
            return;
        }
        this.date = value;
        if (isAttached()) {
            suppressChangeEvent = !fireEvents;
            setPickerDate(JsDate.create((double) value.getTime()), pickatizedDateInput);
            suppressChangeEvent = false;
            label.addStyleName(CssName.ACTIVE);
        }
        super.setValue(value, fireEvents);
    }

you can see, that setValue() calls setPickerDate(JsDate.create((double) value.getTime()), pickatizedDateInput); only when the DatePicker isAttached(). But getValue() returns PickerDate unconditionally.

So when the Editor Framework calls getValue() it will return null when the DatePicker is not attached, although this.date got set correctly.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions