]> git.mxchange.org Git - friendica.git/commitdiff
Prevent comment UI from closing when using BBCode buttons with empty textarea
authorHypolite Petovan <mrpetovan@gmail.com>
Wed, 19 Apr 2017 02:03:49 +0000 (22:03 -0400)
committerHypolite Petovan <mrpetovan@gmail.com>
Wed, 19 Apr 2017 02:03:49 +0000 (22:03 -0400)
view/theme/frio/js/theme.js
view/theme/frio/templates/comment_item.tpl

index 4e32f9128c496ff3dc94cb72036e2256bd6d0ca4..27dd296e5f4036ce3c23e9360810de6adbdf071b 100644 (file)
@@ -275,6 +275,30 @@ $(document).ready(function(){
 
        });
 
+       /*
+        * This event handler hides all comment UI when the user clicks anywhere on the page
+        * It ensures that we aren't closing the current comment box
+        *
+        * We are making an exception for buttons because of a race condition with the
+        * comment opening button that results in an already closed comment UI.
+        */
+       $(document).on('click', function(event) {
+               if (event.target.type === 'button') {
+                       return true;
+               }
+
+               var $dontclosethis = $(event.target).closest('.wall-item-comment-wrapper').find('.comment-edit-form');
+               $('.wall-item-comment-wrapper .comment-edit-submit-wrapper:visible').each(function() {
+                       var $parent = $(this).parent('.comment-edit-form');
+                       var itemId = $parent.data('itemId');
+
+                       if ($dontclosethis[0] != $parent[0]) {
+                               var textarea = $parent.find('textarea').get(0)
+
+                               commentCloseUI(textarea, itemId);
+                       }
+               });
+       });
 
 });
 
index 8ce7805bbd4785ac0b19b6b4d7163c44a1f74945..168576b3d4ca4c4d8345fbd16b6a95810c183326 100644 (file)
@@ -4,7 +4,7 @@
 {{else}}
 <div class="comment-wwedit-wrapper" id="comment-edit-wrapper-{{$id}}" style="display: block;">
 {{/if}}
-       <form class="comment-edit-form" style="display: block;" id="comment-edit-form-{{$id}}" action="item" method="post" onsubmit="post_comment({{$id}}); return false;">
+       <form class="comment-edit-form" style="display: block;" data-item-id="{{$id}}" id="comment-edit-form-{{$id}}" action="item" method="post" onsubmit="post_comment({{$id}}); return false;">
                <input type="hidden" name="type" value="{{$type}}" />
                <input type="hidden" name="profile_uid" value="{{$profile_uid}}" />
                <input type="hidden" name="parent" value="{{$parent}}" />
@@ -14,7 +14,7 @@
                <input type="hidden" name="post_id_random" value="{{$rand_num}}" />
 
                <div class="bb form-group">
-                       <textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty form-control text-autosize" name="body" placeholder="{{$comment}}" onFocus="commentOpenUI(this,{{$id}});" onBlur="commentCloseUI(this,{{$id}});"></textarea>
+                       <textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty form-control text-autosize" name="body" placeholder="{{$comment}}" onFocus="commentOpenUI(this,{{$id}});"></textarea>
                </div>
                {{if $qcomment}}
                        <select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">