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

feat(quantic): Allow RGA component to provide a custom "no answer" message when no answer is shown #4919

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

SimonMilord
Copy link
Contributor

@SimonMilord SimonMilord commented Jan 30, 2025

SFINT-5926

IN THIS PR:

  • Added the possibility for Quantic users to pass a slot with name=no-answer-message to the quanticGeneratedAnswer component to display a custom error message whenever CRGA could not return an answer. If no slot is passed, we simply display nothing
  • Covered this new logic with unit tests

Notes about the solution:

  • To display the custom error message, 2 conditions are required: 1) the state cannotAnswer was returned as true and 2) the Quantic user has passed a named slot in the component.
  • We are using a hidden slot to detect whether a slot was passed to the component, which allows us to check slot presence for the shouldDisplayNoAnswerMessage check and display the no answer HTML properly. This was the best way possible as LWC doesnt allow for conditional rendering and as it keeps the additional logic to make this feature work to a minimum in the JS file.

DEMO:

Screen.Recording.2025-02-20.at.4.36.57.PM.mov

TESTS:

image

Copy link

github-actions bot commented Jan 30, 2025

Pull Request Report

PR Title

❌ Title should follow the conventional commit spec:
<type>(optional scope): <description>

Example: feat(headless): add result-list controller

Live demo links

Bundle Size

File Old (kb) New (kb) Change (%)
case-assist 243.7 243.7 0
commerce 355 355 0
search 415 415 0
insight 406.2 406.2 0
recommendation 255.9 255.9 0
ssr 408.8 408.8 0
ssr-commerce 372.7 372.7 0

@SimonMilord SimonMilord marked this pull request as ready for review February 20, 2025 21:48
@SimonMilord SimonMilord requested a review from a team as a code owner February 20, 2025 21:48
Copy link
Collaborator

@erocheleau erocheleau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good to me! One suggestion of a clearer name, but take it or leave it, up to you

* @example
* <c-quantic-generated-answer engine-id={engineId} with-toggle collapsible></c-quantic-generated-answer>
* <c-quantic-generated-answer engine-id={engineId} with-toggle collapsible>
* <div slot="no-answer-message">No answer was generated.</div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it slot= or name= ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is slot, name is for the element :P

return !!slot?.assignedNodes()?.length;
}

get shouldDisplayNoAnswerMessage() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe to be more specific as only a custom message would ever display a "no answer message"?

Suggested change
get shouldDisplayNoAnswerMessage() {
get shouldDisplayCustomNoAnswerMessage() {

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

Successfully merging this pull request may close these issues.

2 participants