mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-16 20:49:00 -04:00
Change context for cancel link
Every other control refers to the group name so the cancel link should too.
This commit is contained in:
@@ -19,10 +19,10 @@
|
|||||||
this.states = [
|
this.states = [
|
||||||
{key: 'nothing-selected-buttons', $el: this.$form.find('#nothing_selected'), cancellable: false},
|
{key: 'nothing-selected-buttons', $el: this.$form.find('#nothing_selected'), cancellable: false},
|
||||||
{key: 'items-selected-buttons', $el: this.$form.find('#items_selected'), cancellable: false},
|
{key: 'items-selected-buttons', $el: this.$form.find('#items_selected'), cancellable: false},
|
||||||
{key: 'move-to-existing-folder', $el: this.$form.find('#move_to_folder_radios'), cancellable: true, setFocus: this.getFocusRoutine('#move_to_folder_radios fieldset', true)},
|
{key: 'move-to-existing-folder', $el: this.$form.find('#move_to_folder_radios'), cancellable: true, setFocus: this.getFocusRoutine('#move_to_folder_radios fieldset', true), action: 'move to folder'},
|
||||||
{key: 'move-to-new-folder', $el: this.$form.find('#move_to_new_folder_form'), cancellable: true, setFocus: this.getFocusRoutine('#move_to_new_folder_name', false)},
|
{key: 'move-to-new-folder', $el: this.$form.find('#move_to_new_folder_form'), cancellable: true, setFocus: this.getFocusRoutine('#move_to_new_folder_name', false), action: 'move to new folder'},
|
||||||
{key: 'add-new-folder', $el: this.$form.find('#add_new_folder_form'), cancellable: true, setFocus: this.getFocusRoutine('#add_new_folder_name', false)},
|
{key: 'add-new-folder', $el: this.$form.find('#add_new_folder_form'), cancellable: true, setFocus: this.getFocusRoutine('#add_new_folder_name', false), action: 'new folder'},
|
||||||
{key: 'add-new-template', $el: this.$form.find('#add_new_template_form'), cancellable: true, setFocus: this.getFocusRoutine('#add_new_template_form fieldset', true)}
|
{key: 'add-new-template', $el: this.$form.find('#add_new_template_form'), cancellable: true, setFocus: this.getFocusRoutine('#add_new_template_form fieldset', true), action: 'new template'}
|
||||||
];
|
];
|
||||||
|
|
||||||
// cancel/clear buttons only relevant if JS enabled, so
|
// cancel/clear buttons only relevant if JS enabled, so
|
||||||
@@ -88,7 +88,7 @@
|
|||||||
this.selectActionButtons(selector);
|
this.selectActionButtons(selector);
|
||||||
},
|
},
|
||||||
'cancelSelector': selector,
|
'cancelSelector': selector,
|
||||||
'nonvisualText': "this step"
|
'nonvisualText': state.action
|
||||||
});
|
});
|
||||||
|
|
||||||
state.$el.find('[type=submit]').after($cancel);
|
state.$el.find('[type=submit]').after($cancel);
|
||||||
|
|||||||
@@ -386,6 +386,8 @@ describe('TemplateFolderForm', () => {
|
|||||||
const cancelLink = formControls.querySelector('.js-cancel');
|
const cancelLink = formControls.querySelector('.js-cancel');
|
||||||
|
|
||||||
expect(cancelLink).not.toBeNull();
|
expect(cancelLink).not.toBeNull();
|
||||||
|
expect(cancelLink.querySelector('.govuk-visually-hidden')).not.toBeNull();
|
||||||
|
expect(cancelLink.querySelector('.govuk-visually-hidden').textContent.trim()).toEqual('new template');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -471,6 +473,16 @@ describe('TemplateFolderForm', () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("should show a 'Cancel' link", () => {
|
||||||
|
|
||||||
|
const cancelLink = formControls.querySelector('.js-cancel');
|
||||||
|
|
||||||
|
expect(cancelLink).not.toBeNull();
|
||||||
|
expect(cancelLink.querySelector('.govuk-visually-hidden')).not.toBeNull();
|
||||||
|
expect(cancelLink.querySelector('.govuk-visually-hidden').textContent.trim()).toEqual('new folder');
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
test("should focus the textbox", () => {
|
test("should focus the textbox", () => {
|
||||||
|
|
||||||
expect(document.activeElement).toBe(textbox);
|
expect(document.activeElement).toBe(textbox);
|
||||||
@@ -663,6 +675,16 @@ describe('TemplateFolderForm', () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("should show a 'Cancel' link", () => {
|
||||||
|
|
||||||
|
const cancelLink = formControls.querySelector('.js-cancel');
|
||||||
|
|
||||||
|
expect(cancelLink).not.toBeNull();
|
||||||
|
expect(cancelLink.querySelector('.govuk-visually-hidden')).not.toBeNull();
|
||||||
|
expect(cancelLink.querySelector('.govuk-visually-hidden').textContent.trim()).toEqual('move to folder');
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
test("focus the 'Choose a folder' fieldset", () => {
|
test("focus the 'Choose a folder' fieldset", () => {
|
||||||
|
|
||||||
expect(document.activeElement).toBe(formControls.querySelector('#move_to'));
|
expect(document.activeElement).toBe(formControls.querySelector('#move_to'));
|
||||||
@@ -735,6 +757,16 @@ describe('TemplateFolderForm', () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("should show a 'Cancel' link", () => {
|
||||||
|
|
||||||
|
const cancelLink = formControls.querySelector('.js-cancel');
|
||||||
|
|
||||||
|
expect(cancelLink).not.toBeNull();
|
||||||
|
expect(cancelLink.querySelector('.govuk-visually-hidden')).not.toBeNull();
|
||||||
|
expect(cancelLink.querySelector('.govuk-visually-hidden').textContent.trim()).toEqual('move to new folder');
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
test("should focus the textbox", () => {
|
test("should focus the textbox", () => {
|
||||||
|
|
||||||
expect(document.activeElement).toBe(textbox);
|
expect(document.activeElement).toBe(textbox);
|
||||||
|
|||||||
Reference in New Issue
Block a user