taiga-family / taiga-ui

Angular UI Kit and components library for awesome people

Home Page:https://taiga-ui.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🐞 - TuiError produce an error with PolymorpheusComponent

EricPoul opened this issue Β· comments

Playground Link

https://stackblitz.com/edit/angular-mwny1a?file=src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.module.ts&hideExplorer=1

Description

When I provide the TUI_VALIDATION_ERRORS object with PolymorpheusComponent as a value in it an error occurs Error: Cannot create a proxy with a non-object as target or handler. It's because required error has true value here. Also, I haven't seen any examples with components on the Taiga.ui and this issue hadn't been faced with before but since TUI_VALIDATION_ERRORS allows PolymorpheusContent I'm expecting it works properly with PolymorpheusComponent.

Angular version

12.2.17

Taiga UI version

3.79.0

Which browsers have you used?

  • Chrome
  • Firefox
  • Safari
  • Edge

Which operating systems have you used?

  • macOS
  • Windows
  • Linux
  • iOS
  • Android

Looks like the only way to fix it would be to wrap primitive values into objects, but that would be breaking change πŸ€”

It can be wrapped only for components and templates but if it didn't work before could it be considered as a breaking change?πŸ˜„

If we manage to do it only for components and templates β€” it won't be breaking :)

It would work but you won't be able to get value of the error since templates can only access keys of the context object:

<ng-template #tmp let-value="key">{{ value }}</ng-template>

Yep, so the goal is to try to wrap a primitive into the object for templates and components? It shouldn't be a breaking change for templates since it didn't work properly before(did work only if you hadn't reached a context). Is it a priority bug for you or should I consider making a PR?

We are currently working very hard to finish 4.0 so this won't be on our radar for a while. You can think on the fix in the meantime. I wonder if it's better to fix it in polymorpheus so it works everywhere. Current main in polymorpheus is the upcoming major release, fyi.

Why not just use @ngneat/error-tailor and avoid the tui-error boilerplate altogether?

Moving it to ng-polymorpheus: taiga-family/ng-polymorpheus#449