adopted-ember-addons / adopted-ember-addons/ember-paper

Paper Select 'required' behaviour doesn't work when 'selected' is set to an empty promise

Đang mở
#844 1 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
879
Fork
327
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

A `{{paper-select}}` component in a `{{paper-form}}` and bound to a `belongsTo` relationship does not behave correctly when `required=true`, if the relationship is empty and the `selected` property is set to the related model. For example, if `selected=model.otherModel` when there is no associated `otherModel`. The reason seems to be that when there isn't a related model, `model.otherModel` is equal to an Ember Data PromiseObject whose `content` is `null`, instead of `model.otherModel` actually being `null` itself.

The result is that the `*` to indicate that the field is required doesn't appear, and the form passes validation even when no value is selected. The correct behaviour can be obtained by setting `selected=(if model.otherModel.id model.otherModel)` so that `selected` is `null` when the other model is missing.

I've created a [demo repo](https://github.com/mikeu/paper-select-related-null) that reproduces the issue.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.