DavyJonesLocker / ember-one-way-controls

Native one way input

Home Page:http://ember-twiddle.com/2d7246875098d0dbb4a4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

one-way-select not accepting SafeString as its `prompt` param

bardzusny opened this issue · comments

One-way-select doesn't display SafeString instances passed as its prompt parameter values - due to primitive typeof check in promptText computed property: https://github.com/DockYard/ember-one-way-controls/blob/master/addon/components/one-way-select.js#L126 .

Common use-case for this is using translated strings (ember-i18n):

{{one-way-select
  ...
  prompt=(t 'select.placeholder.text')
}}

Current workaround is to override aforementioned promptText computed property by hand:

{{one-way-select
  ...
  prompt='no one will see me anyway'
  promptText=(t 'select.placeholder.text')
}}

Twiddle with reproduced issue (and current workaround): https://ember-twiddle.com/00fee438383f6db62c717c03d2bbb5dd?openFiles=templates.application.hbs%2C .

Will be happy to submit PR with fix - my first thought is to remove promptText computed altogether, or just make it coerce prompt into String (making it kind of redundant?). Any other suggestions?

I am not quite sure why we have a separate CP for this, maybe @martndemus remembers?

Plunged ahead and created PR removing aforementioned promptText CP: #131 . Didn't find any test case or just practical use for it (unless we'd rather display nothing than stringified Object when someone passes it as prompt :) ).