ember-bulma
ember-bulma copied to clipboard
Modal, prevent null action error for onclose
In the demo, we provide an onclose
action conditionally, and a null
value can be passed as a closure action, which is not allowed in 2.13.
Can either update the demo here to demonstrate the following:
{{bulma-modal show=showModal onclose=(if showModal (toggle 'showModal' this) (action 'noOp'))}}
or provide a noOp as the default onclose
value
@crodriguez1a Seems like conditionally setting the onclose
action is a side-effect of using the show
attr to show/hide the modal. What if we slightly changed the implementation, where we instruct users to use the if
helper ->
{{if showModal}}
{{bulma-modal onclose=(toggle 'showModal' this)}}
{{/if}}
Some advantages I see with this are:
-
{{bulma-modal}}
could properly take advantage of component lifecyle hooks (i.e.didInsertElement
andwillDestroyElement
) - able to remove the conditional
onclose
action - the
{{bulma-modal}}
component is only in the DOM when needed - more like other implementations (e.g. ember-modal-dialog)
@jbailey4's suggestion seems like the idiomatic approach to me