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

[FOR TESTING WITH LIVEMAIL ENV] Give banner role=status if just an update #5387

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/assets/javascripts/esm/focus-banner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FocusBanner {

// focus success and error banners when they appear in any content updates
$(document).on("updateContent.onafterupdate", function(evt, el) {
this.focusBanner($(".banner-dangerous, .banner-default-with-tick", el));
this.focusBanner($(".banner-dangerous", el));
}.bind(this));
}

Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/banner.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% macro banner(body, type=None, with_tick=False, delete_button=None, subhead=None, context=None, action=None, id=None, thing=None) %}
<div
class='banner{% if type %}-{{ type }}{% endif %}{% if with_tick %}-with-tick{% endif %}'
role='alert'
{% if type == 'dangerous' %}role="alert"{% else %}role="status"{% endif %}
{% if id %}
id={{ id }}
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

<div class="ajax-block-container">
{% if verification_status == "pending" %}
<div role="status"></div>
{{ page_header('Checking email reply-to address') }}
<p class="govuk-body">
We’re checking that ‘{{ reply_to_email_address }}’ is a real email address.
Expand All @@ -19,7 +20,6 @@
</p>
{% elif verification_status == "success" %}
{{ banner("‘{}’ is ready to use".format(reply_to_email_address), type='default', with_tick=True) }}

{{ page_header('Checking email reply-to address') }}
<div class="js-stick-at-bottom-when-scrolling">
{{ govukButton({
Expand Down
29 changes: 0 additions & 29 deletions tests/javascripts/focus-banner.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,35 +56,6 @@ describe('Focus banner', () => {

});

test('If there is a div.banner-default-with-tick in the updated content, it should be focused', () => {

document.body.innerHTML = `
<div class="ajax-block-container">
</div>`;

const ajaxBlockContainer = document.querySelector('.ajax-block-container');

(new FocusBanner());

ajaxBlockContainer.innerHTML = `
<div class="banner-default-with-tick">
<h2>This is a problem with your upload</h2>
<p>The file uploaded needs to be a PNG</p>
</div>`;

// simulate a content update event
$(document).trigger('updateContent.onafterupdate', ajaxBlockContainer);

const bannerEl = document.querySelector('.banner-default-with-tick');

expect(document.activeElement).toBe(bannerEl);

$(bannerEl).trigger('blur');

expect(bannerEl.hasAttribute('tabindex')).toBe(false);

});

});

});