Skip to content

Created new studioBanner for form validation#5214

Merged
MisRob merged 14 commits into
learningequality:unstablefrom
yeshwanth235:issue-5082
Sep 3, 2025
Merged

Created new studioBanner for form validation#5214
MisRob merged 14 commits into
learningequality:unstablefrom
yeshwanth235:issue-5082

Conversation

@yeshwanth235
Copy link
Copy Markdown
Contributor

Summary

Created a new studioBanner for form validation.
Replaced Banner component with new studioBanner

Screenshots:
Screenshot 2025-07-28 at 2 28 36 PM
Screenshot 2025-07-28 at 2 29 12 PM
Screenshot 2025-07-28 at 2 28 44 PM
Screenshot 2025-07-28 at 2 29 01 PM

References

5082

Reviewer guidance

Check storage request form validation.
If there are any errors new banner should be shown.
On change of any field. Should update error count in banner

@MisRob
Copy link
Copy Markdown
Member

MisRob commented Jul 29, 2025

Thanks @yeshwanth235! High-level it is aligned with expectations. We will assign someone for a detailed review soon.

Meanwhile, would you be able to update to align with this acceptance criteria?

If there is no unit test suite, a new one is created. Do not use obsolete @vue/test-utils approach. Instead, use Vue Testing Library.

It should be a straightforward update - let us know if you had any questions.

And for accessibility, I forgot to mention it in the issue - to make error information accessible to screen readers, could you use useKLiveRegion to send a polite (recommended by our a11y lead) message to the live region when the error banner text is displayed? The message should be translated and the same as error banner text.

@yeshwanth235
Copy link
Copy Markdown
Contributor Author

yeshwanth235 commented Jul 29, 2025

Added the useKliveRegion @MisRob

One doubt regarding test cases. Instead of using @vue/test-utils. Are you suggesting to use @testing-library/vue for writing test case?

@MisRob
Copy link
Copy Markdown
Member

MisRob commented Jul 29, 2025

Yes @yeshwanth235

@yeshwanth235
Copy link
Copy Markdown
Contributor Author

updated the test cases @MisRob
please help to review

@MisRob
Copy link
Copy Markdown
Member

MisRob commented Jul 31, 2025

Thanks @yeshwanth235. My good colleague @AllanOXDi will review your pull request :)

@AllanOXDi AllanOXDi self-requested a review August 5, 2025 11:20
Copy link
Copy Markdown
Contributor

@AllanOXDi AllanOXDi left a comment

Choose a reason for hiding this comment

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

Thanks @yeshwanth235 for the great work on this! 🙌 Overall, everything looks good A few notes and suggestions - I am not sure why the error is persistent but not showing me the required field

Comment thread contentcuration/contentcuration/frontend/shared/views/StudioBanner.vue Outdated
},
},
watch: {
errorText(newText) {
Copy link
Copy Markdown
Contributor

@AllanOXDi AllanOXDi Aug 7, 2025

Choose a reason for hiding this comment

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

This block only runs when the errorText prop changes. It does NOT run if
the error prop changes from false to true while the text stays the same. Th banner may appears with error: false and errorText: and error becomes True, but errorText doesn't change. I think we should also watch the error prop or, even better, watch a computed property that combines both error and errorText to decide when to announce

Copy link
Copy Markdown
Member

@MisRob MisRob Aug 8, 2025

Choose a reason for hiding this comment

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

If we were to announce every error count update, then yes, this would make much sense.

However, I'd like to suggest not using watcher to not overwhelm screen reader users whose experience is different from those that are sighted. Sighted users perceive more kinds of information at once. Screen reader users get information in a linear way, one by one, and if there's too much of it, it can get difficult.

For now, instead of using watcher, let's only announce banner error text after user clicks submit button. That will be the most reasonable start. Later when we have a11y QA in Studio, we can further adjust if needed (there will likely be more work in this form anyway that's not in scope of this particular task).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, will update it misRob

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems that announcing got lost completely in the last version @yeshwanth235. Were there any issues with implementing what's suggested?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry, my bad. Will update it @MisRob

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No problem, thanks

expect(screen.getByText(sampleInfoMessage)).toBeInTheDocument();
});

test('error true with errorText', () => {
Copy link
Copy Markdown
Contributor

@AllanOXDi AllanOXDi Aug 7, 2025

Choose a reason for hiding this comment

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

None blocking: it may be good to add a test for when errorText is empty or error is false to ensure the banner still renders correctly without triggering sendPoliteMessage.

mockSendPoliteMessage.mockClear();
});

test('smoke test - with default props', () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

renaming this to something like renders banner with error text to describe behavior more explicitly.

@AllanOXDi
Copy link
Copy Markdown
Contributor

Screen.Recording.2025-08-07.at.15.58.59.mov

@yeshwanth235
Copy link
Copy Markdown
Contributor Author

Will check it, and will push the changes.

@yeshwanth235
Copy link
Copy Markdown
Contributor Author

Screen.Recording.2025-08-07.at.15.58.59.mov

I check this issue. It is happening in main branch as well. Can you please help to create an issue. @AllanOXDi

The validation error is now showing for this field
image

@MisRob
Copy link
Copy Markdown
Member

MisRob commented Aug 13, 2025

Hi @yeshwanth235 and @AllanOXDi - I wanted to note that after it's re-reviewed, let's wait for merging until I let you know. This is due to pre-release preparations, and will take only a couple of days.

Yes @yeshwanth235, you don't need to fix something that was present on unstable before and reporting as a new issue together with @AllanOXDi will be best.

@MisRob
Copy link
Copy Markdown
Member

MisRob commented Aug 22, 2025

@AllanOXDi @yeshwanth235 I was just notified, we can merge PRs now. Allan, do you have any other feedback?

<template>

<div
class="banner notranslate"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is notranslate here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since div contains text. Hence kept the class.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

notranslate is only for some user-generated texts. To prevent Google Translate from translating it.

So here can be removed.

It's a bit nuanced. Generally when working on Studio, you can remember that for anything that's application text, we don't want to prevent translation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One of my colleagues recently summed it up nicely. Hopefully it helps to understand.

Studio's UI isn't translated into as many languages as Kolibri, but being an online service, we've supported using in-browser Google Translate as an option for those unsupported languages. The notranslate class then tries to align that behavior like it was a UI language option-- only translating Studio's UI and not user-generated text.

@AllanOXDi
Copy link
Copy Markdown
Contributor

AllanOXDi commented Aug 22, 2025

Let me re review it


const banner = screen.getByTestId('studio-banner');
expect(banner).toBeInTheDocument();
expect(banner).toHaveClass('banner', 'notranslate');
Copy link
Copy Markdown
Member

@MisRob MisRob Aug 22, 2025

Choose a reason for hiding this comment

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

There's no need to test for presence of classes - it doesn't really say that much about resulting user experience, and also ties tests to internal implementation.

@yeshwanth235
Copy link
Copy Markdown
Contributor Author

Thanks for review @MisRob

Updated the PR. Please help to review @AllanOXDi and @MisRob

Copy link
Copy Markdown
Member

@MisRob MisRob left a comment

Choose a reason for hiding this comment

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

Thanks @yeshwanth235, two last notes from me. Unless @AllanOXDi has some feedback, I believe we can then merge.

}

.studio-banner {
margin-top: 8px !important;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why was !important needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will check and update it

const slotContent = this.$slots.default;
const textContent = slotContent[0].text;
if (textContent && this.error) {
this.sendPoliteMessage(textContent);
Copy link
Copy Markdown
Member

@MisRob MisRob Aug 27, 2025

Choose a reason for hiding this comment

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

Almost there :) Screen reader now properly announces the error message when I click "Send request" for the first time, while not announcing each dynamic change to error count as I requested 👍

However when I fix few errors, but not all of them, and click the button again, it doesn't announce. This is because the same banner is displayed, and mounted is not executed again. Maybe we could simply sendPoliteMessage in Send request click handler, outside StudioBanner component? Since StudioBanner itself doesn't really have enough context to distinguish between what's dynamic error count updates and what's the error message when the form is clicked again.

Copy link
Copy Markdown
Contributor Author

@yeshwanth235 yeshwanth235 Aug 29, 2025

Choose a reason for hiding this comment

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

Made changes @MisRob. Thanks for the suggestion.

Now sendPoliteMessage will be called in onValidationFailed. Which is triggered by form validation. So from now on when ever the submit is click. If there are any errors sendPoliteMessage will be sent.

Copy link
Copy Markdown
Contributor

@AllanOXDi AllanOXDi left a comment

Choose a reason for hiding this comment

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

LGTM! , Will differ to @MisRob for the final review

Copy link
Copy Markdown
Member

@MisRob MisRob left a comment

Choose a reason for hiding this comment

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

Thanks @yeshwanth235 @AllanOXDi.

Nice work. Screen reader now reports in a balanced manner 👍

@MisRob MisRob dismissed AllanOXDi’s stale review September 3, 2025 14:20

Allan approved above

@MisRob MisRob merged commit c211626 into learningequality:unstable Sep 3, 2025
13 checks passed
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.

5 participants