ember-bulma icon indicating copy to clipboard operation
ember-bulma copied to clipboard

Modal, prevent null action error for onclose

Open crodriguez1a opened this issue 7 years ago • 2 comments

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 avatar Jun 01 '17 14:06 crodriguez1a

@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 and willDestroyElement)
  • 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 avatar Jul 29 '17 12:07 jbailey4

@jbailey4's suggestion seems like the idiomatic approach to me

alexdiliberto avatar Jul 29 '17 19:07 alexdiliberto