Browse Source

Fixes: Mobile - Enable the Done button only when the article edit form group becomes dirty.

Dusan Vuckovic 2 years ago
parent
commit
0f829612cf

+ 2 - 1
app/frontend/apps/mobile/pages/ticket/components/TicketDetailView/ArticleReplyDialog.vue

@@ -108,9 +108,10 @@ const close = () => {
     </template>
     <template #after-label>
       <button
-        class="grow text-blue"
+        class="grow text-blue disabled:opacity-50"
         tabindex="0"
         role="button"
+        :disabled="!dialogFormIsDirty"
         @pointerdown.stop
         @click="close()"
         @keypress.space.prevent="close()"

+ 16 - 0
spec/system/apps/mobile/tickets/ticket_create_article_spec.rb

@@ -22,10 +22,26 @@ RSpec.describe 'Mobile > Ticket > Create article', app: :mobile, authenticated_a
 
   def open_article_dialog
     visit "/tickets/#{ticket.id}"
+
+    wait_for_form_to_settle('form-ticket-edit')
+
     find_button('Add reply').click
   end
 
   context 'when creating a new article as an agent', authenticated_as: :agent do
+    it 'disables the done button when the form is not dirty' do
+      open_article_dialog
+
+      expect(find_button('Done', disabled: true).disabled?).to be(true)
+    end
+
+    it 'enables the done button when the form is dirty' do
+      open_article_dialog
+      find_editor('Text').type('foobar')
+
+      expect(find_button('Done').disabled?).to be(false)
+    end
+
     it 'creates an internal note (default)' do
       open_article_dialog