Commit ffe164fb authored by Daniel Tian's avatar Daniel Tian

Fix vulnerability save button spinner position

parent 2cd93646
...@@ -135,7 +135,7 @@ export default { ...@@ -135,7 +135,7 @@ export default {
<template> <template>
<history-comment-editor <history-comment-editor
v-if="isEditingComment" v-if="isEditingComment"
class="discussion-reply-holder m-3" class="discussion-reply-holder"
:initial-comment="commentNote" :initial-comment="commentNote"
:is-saving="isSavingComment" :is-saving="isSavingComment"
@onSave="saveComment" @onSave="saveComment"
......
<script> <script>
import { GlFormTextarea, GlButton, GlLoadingIcon } from '@gitlab/ui'; import { GlFormTextarea, GlButton } from '@gitlab/ui';
export default { export default {
components: { GlFormTextarea, GlButton, GlLoadingIcon }, components: { GlFormTextarea, GlButton },
props: { props: {
initialComment: { initialComment: {
type: String, type: String,
...@@ -43,9 +43,9 @@ export default { ...@@ -43,9 +43,9 @@ export default {
ref="saveButton" ref="saveButton"
variant="success" variant="success"
:disabled="isSaveButtonDisabled" :disabled="isSaveButtonDisabled"
:loading="isSaving"
@click="$emit('onSave', trimmedComment)" @click="$emit('onSave', trimmedComment)"
> >
<gl-loading-icon v-if="isSaving" class="mr-1" />
{{ __('Save comment') }} {{ __('Save comment') }}
</gl-button> </gl-button>
<gl-button ref="cancelButton" class="ml-1" :disabled="isSaving" @click="$emit('onCancel')"> <gl-button ref="cancelButton" class="ml-1" :disabled="isSaving" @click="$emit('onCancel')">
......
---
title: Fix vulnerability save button spinner position
merge_request: 40781
author:
type: fixed
...@@ -51,20 +51,19 @@ describe('History Comment Editor', () => { ...@@ -51,20 +51,19 @@ describe('History Comment Editor', () => {
expect(wrapper.emitted().onCancel).toHaveLength(1); expect(wrapper.emitted().onCancel).toHaveLength(1);
}); });
it('disables the save button when there is no text or only whitespace in the textarea', () => { it('disables the save button when there is no text or only whitespace in the textarea', async () => {
createWrapper({ initialComment: 'some comment' }); createWrapper({ initialComment: 'some comment' });
textarea().vm.$emit('input', ' '); textarea().vm.$emit('input', ' ');
await wrapper.vm.$nextTick();
return wrapper.vm.$nextTick().then(() => { expect(saveButton().props('disabled')).toBe(true);
expect(saveButton().attributes('disabled')).toBeTruthy();
});
}); });
it('disables all elements when the isSaving prop is true', () => { it('disables all elements when the comment is being saved', () => {
createWrapper({ isSaving: true }); createWrapper({ isSaving: true });
expect(textarea().attributes('disabled')).toBeTruthy(); expect(textarea().attributes('disabled')).toBeTruthy();
expect(saveButton().attributes('disabled')).toBeTruthy(); expect(saveButton().props('loading')).toBe(true);
expect(cancelButton().attributes('disabled')).toBeTruthy(); expect(cancelButton().props('disabled')).toBe(true);
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment