Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Notify - define action as non-dismissing by prop #1847

Closed
danikane opened this issue Mar 27, 2018 · 4 comments
Closed

[Enhancement] Notify - define action as non-dismissing by prop #1847

danikane opened this issue Mar 27, 2018 · 4 comments
Milestone

Comments

@danikane
Copy link

danikane commented Mar 27, 2018

Hi, I just saw you're adding an onDismiss handler to Notify, good stuff!
I was wondering whether you could add another prop to the config object for the action items, for example willDismiss, type Boolean, default true.
Currently the code for Notify is like:

        if (notif.actions) {
          notif.actions = config.actions.map(item => {
            const
              handler = item.handler,
              action = clone(item)
            action.handler = typeof handler === 'function'
              ? () => {
                handler()
                close()
              }
              : () => close()
            return action
          })
        }

Currently any action closes the Notify.
What I suggest is something like:

        if (notif.actions) {
          notif.actions = config.actions.map(item => {
            const
              willDismiss = item.willDismiss || true
              handler = item.handler,
              action = clone(item)
            action.handler = typeof handler === 'function'
              ? () => {
                handler()
                if (willDismiss) close()
              }
              : () => close()
            return action
          })
        }

Turn it around, make it a noDismiss, true and for example
noDismiss ? null : close()
if you think is better approach. :)
I can do a PR if this addition makes sense.

@danikane danikane changed the title [PROPOSAL] Notify - define action as non-dismissing by prop [Enhancement] Notify - define action as non-dismissing by prop Mar 27, 2018
@pdanpdan
Copy link
Collaborator

Which would be the use case for a notification you want to keep visible after selecting an action?
The action should act as an acknowledge for the notification.
I think you can show another notification after the current one closes, because I would expect the action from the first one changes something.

@danikane
Copy link
Author

danikane commented Mar 28, 2018

Hi and thanks for asking. 😄
The reason behind this request is a use case on a web map app. See screenshot below.
The Notify component is a great upgrade to the Toast and is used as a placeholder for info regarding a polygon drawn (therefore the 0 timeout). Whenever I dismiss the Notify I remove the polygon from the map.
The additional non-dismissing action would enable me for example to highlight/flash/pan to the shape drawn or all of the above from the same spot (the Notify component) without removing the shape.

image
If there is an alternative that comes to your mind please share it.
I can try to build a custom component, but the Notify works so good, especially with multiple instances that stack on top of each other. 😄

@rstoenescu
Copy link
Member

Added "noDismiss" prop to actions. Available in 0.15.11.

@danikane
Copy link
Author

Amazing! Thanks, man. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants