gcds-components
gcds-components copied to clipboard
feat: gcds-error-summary should accommodate duplicate keys
Prerequisites | Prérequis
- [x] I've read the Contributing Guidelines. | J’ai lu les Lignes directrices sur les contributions.
- [x] I agree to follow the Code of Conduct. | J’accepte de me conformer au Code de conduite.
- [x] I've searched for existing issues that already report this problem, without success. | J’ai vérifié parmi les tickets (issues) existants que ce sujet n’avait pas déjà été soumis.
Describe the feature request. | Décrivez la fonctionnalité demandée
Hello, we are requesting functionality such that the gcds-error-summary can accept multiple errors with duplicate keys.
Describe the use case. | Décrivez les cas d’utilisation
- The main reason is that we have multiple errors on a single field in some cases, and JS forbids objects with duplicate keys.
- I also find it unnatural to use an object here, though this may be a question of taste. But let me make my case: a list of errors would tend to be iterable; we process a known set of fields to figure out what the errors should be. Given the signature that gcds-error-summary requests, we have to do a
Array.reduce( ... , {})in a computed binding downstream from our errors object to make it work properly, instead of simply plucking out certain keys. - Furthermore, one of the main advantages of using an object here would in theory be having access to an object prototype, but that is not really useful in this scenario.
Describe the preferred solution. | Décrivez la solution souhaitée
Perhaps in addition to accepting an object keyed by href,
{ errorLocation1: "An error description 1",
errorLocation2: "An error description 2" }
it might also accept an array:
[ { href: "errorLocation1", message: "An error description 1" },
{ href: "errorLocation2", message: "An error description 2" } ]
Describe all alternatives. | Décrivez toutes les solutions possibles
Maybe an individual key could also accept an array:
{ errorLocation1: [ "Message 1", "Message 2" ],
errorLocation2: "Just one message in this spot" }
In this scenario, GCDS would have to decide how to render multiple errors.
Provide related code or examples. | Fournissez du code ou des exemples pertinents
See above
Add other relevant resources. | Ajoutez toute autre ressource utile
Let me know if you need any more clarification! Have a great day!!!