As part of a custom interface, a developer team creates various new Lightning web components. Each of the components handles errors using toast messages. When the development is complete, all the components are added to the same Lightning page.
During acceptance testing, users complain about the long chain of toast messages that display when errors occur loading the components.
Which two techniques should the developer implement to improve the user experience?
Choose 2 answers
The scenario describes a common issue when multiple components are used on the same Lightning page and each component manages its error handling independently, leading to a 'long chain of toast messages' which can be overwhelming for users.
To improve user experience, the developers can implement the following techniques:
A . Use a Lightning web component to aggregate and display all errors: This method involves creating a centralized component responsible for handling all error messages. This component would receive error notifications from other components and then display them in a user-friendly manner. The benefit of this approach is that it provides a single, consistent interface for error messages, reducing the clutter and confusion that can be caused by multiple toasts.
D . Use public properties on each component to display the error messages: By using public properties, components can expose their error states to a parent or orchestrating component, which can then display these errors in a single, consolidated way. This avoids the issue of multiple toast notifications and allows for a more integrated error handling experience.
The other options presented are less ideal:
B . Using the window.alert() method is not recommended in a professional Salesforce environment as it is considered a disruptive way to show errors and does not align with the Salesforce Lightning design system.
C . Using a <template> tag to display in-place error messages could be a viable option for displaying error messages within the component itself, but it does not address the issue of multiple errors stacking up from different components as described in the scenario.
For building a centralized error handling component: Lightning Web Components Developer Guide - Error Handling
For implementing public properties: Lightning Web Components Developer Guide - Public Properties
Cassi
1 days agoKeneth
5 days agoJodi
13 days ago