Closed caseywatts closed 7 years ago
I'm not 100% sure I want to yield it as another ordered parameter, but I don't quite wanna make a separate actions hash for it either lol For this concern, I'm mostly worried about future edits to this addon - it works great as-is, no problem ✨
I tried writing some tests for this feature, but they all suck so far lol: https://github.com/poteto/ember-cli-flash/pull/231
This branch has an integration test now - this PR should be good to go! :)
@sbatson5 could you look over this when you get a chance? :)
@caseywatts sorry for the delay. The test looks good. Just want to pull it into a dummy app real quick and test it. Should be able to get to that tonight
sweet! thanks @sbatson5 :)
I imagine this is a pretty common use case and I'd love to make it super straightforward, too.
--
This is a pretty common fork-in-the-road when designing Ember components. I'm not 100% that my suggestion is the better of the two paths, but I can provide more arguments for it at least :)
@sbatson5 we're also going to want to put some classes on this - that'll lead us to three arguments. Next (and this is probably going too far lol): some people may want this to be a styled button
. If we wanted all of these, the API for this becomes something like this:
get(this, 'flashMessages').success('Success!!', {
flashAction: {
action: this.get('close'),
label: 'Close',
classNames: 'xyz',
tagName: 'button'
}
});
I think a contextual component sort of thing gets around this sort of argument-passing-bloat pretty nicely :)
Also - the last argument close
is optional to write, so I don't believe it'll break any existing code or examples. It should be a ~backwards-compatible change.
@caseywatts ok, you convinced me :). Would you mind just updating the README and just mention to disable destroyOnClick
if you want to use the close
action? Once that's in, we're good to merge 👍
(sorry for the delay)
updated the readme! 🎉
typo corrected ✨
and it's in! 🎉
now that master displays this option, we'll probably want to do a release soon so it matches up? cc @sbatson5 @Dhaulagiri
Unfortunately, I don't have npm access to this package, so we will need @Dhaulagiri to publish and update for us.
published in 1.4.3 🎉
This adds in the ability to close the flash message in your own custom components. I tweaked the example in the readme to include a close button in the template there. I've also tried this in my own app :)
If we like this idea, we should probably make a separate example that has close on click set to false (since currently this example it wouldn't quite make sense why we want the close button when you can click on the whole thing to close it).