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

Cannot override global Notification/Message placement #4323

Closed
lppedd opened this issue Oct 19, 2019 · 6 comments
Closed

Cannot override global Notification/Message placement #4323

lppedd opened this issue Oct 19, 2019 · 6 comments
Assignees

Comments

@lppedd
Copy link
Contributor

lppedd commented Oct 19, 2019

Reproduction link

https://stackblitz.com/edit/angular-i7ihr3

Steps to reproduce

Just change the location from the picker. You'll notice it doesn't take effect.

What is expected?

The notification position should be overridable via

NzMessageBaseService#config(...);

What is actually happening?

The global configuration always overwrite the inputted one in

NzNotificationContainerComponent#setConfig(...) 
NzMessageContainerComponent#mergeMessageConfig(...)
const newConfig = (this.config = {
  ...this.config,
  ...config,
  ...this.nzConfigService.getConfigForComponent(trimComponentName(this.constructor.name))
});

The fix should be pretty straighforward, however it might mean permanently overriding the global value, not only for the single call.


Environment Info
ng-zorro-antd 8.4.0
Browser Any
@wzhudev
Copy link
Member

wzhudev commented Oct 20, 2019

Have you read about this?

If you want to change its position dynamically, you should use set of NzConfigService.

Check this modified version: https://stackblitz.com/edit/angular-i7ihr3-4ggx5w?file=src/app/app.component.ts

@lppedd
Copy link
Contributor Author

lppedd commented Oct 21, 2019

@wendzhue yes I had read that paragraph, and that's basically why I opened this issue.

I think the problem is the NzNotificationService methods (e.g. success, error, info, etc) accept an NzNotificationDataOptions interface, which doesn't have global config's NotificationConfig properties. Thus you cannot really directly override global config.
Also, modifying the global config via NzConfigService for a single call seems dangerous, as you always need to remember to set back the "old" value.

IDK if I explained myself very well, let me know.

@wzhudev
Copy link
Member

wzhudev commented Oct 23, 2019

  1. NotificationConfig is going to replace NzNotificationConfigLegacy not NzNotificationDataOptions.
  2. Why do you have to set back the old value? NzConfigService merges new options with old ones when users call set method. I guess I didn't get your point here.

I opened a PR to change the related docs. Hope it helps. #4327

@lppedd
Copy link
Contributor Author

lppedd commented Oct 23, 2019

@wendzhue Mmh yeah I think we misunderstood each other.

Let's say I want all notifications to be displayed on top-center, thus I set a custom global configuration.
However for a particular usecase I need one on bottom-right.
Currently it seems the only way to do that is by changing the global configuration on-the-fly, and that doesn't feel right to me.

Is this more clear?

@wzhudev
Copy link
Member

wzhudev commented Oct 23, 2019

@lppedd Currently and before, you cannot have a notification whose position is different from others'. PR is welcome! (And we need another issue to disuccess about the feature request.) Actually, this feature has already been implemented in the React version of Ant Design.

@wzhudev
Copy link
Member

wzhudev commented Oct 23, 2019

I am going to close this issue since #4327 was merged. Please open another issue and we can have a furthur discussion about that feature. Thank you!

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

No branches or pull requests

2 participants