Comment and reply edit option added to the Dashboard discussions#2351
Merged
Conversation
Implements inline editing for lesson comments: adds editCommentMutation, updateComment API call, editingId state and handleEditComment in discussions.ts; creates a reusable comment-form template for edit/reply forms; updates lesson-comment-card.php and lesson-comment-single.php to show an edit popover, swap comment display with an edit form, and update the comment text element (tutor-lesson-comment-text-<id>) on success. Adds success/error toasts and preserves existing reply behavior.
Introduce loading and management of discussion replies: add new AJAX endpoint (tutor_load_discussion_replies) and Lesson::load_discussion_replies to return rendered replies HTML. Add templates/dashboard/discussions/comment-replies.php to render replies list and sorting UI. Update frontend JS to support reloadReplies (with order/url param handling), handleReplyComment, setEditing, centralized constants, and better mutation handling (use TutorCore.form/toast/modal, track editingFormId/loadingReplies). Add LOAD_DISCUSSION_REPLIES endpoint constant. Update comment form and comment templates to use consistent form IDs, adjusted props (is_pending, cancel behavior, focused handling), and wire reply/edit/delete flows (confirmation modal now sends is_reply). Overall fixes reply reloads, inline editing UX, and error/success feedback.
Rename lesson-comment template files to a generic comment naming and update all references. Files renamed: lesson-comment-card.php -> comment-card.php, lesson-comment-list.php -> comment-list.php, lesson-comment-single.php -> comment-single.php. Updated templates/dashboard/discussions.php to load comment-list.php and comment-single.php when the current tab is 'lesson-comments', and adjusted the tutor_load_template call to use 'dashboard.discussions.comment-card'. This consolidates naming to be more generic and consistent.
Enable inline editing and updating of Q&A questions and replies and add AJAX-powered replies loading. Key changes: - Add new read.svg icon and register it in icons/types and Icon class. - Add endpoints: UPDATE_QNA and LOAD_QNA_REPLIES. - Frontend (assets/src/js/frontend/dashboard/pages/discussions.ts): add updateQnAMutation, loadQnAReplies mutation, support for reply deletion context, reloadReplies now loads QnA or comment replies based on tab, and setEditing supports 'qna' context; update DOM after successful update and reset reply forms. - Backend (classes/Q_And_A.php): include JsonResponse trait, register tutor_qna_update and tutor_qna_load_replies handlers, implement tutor_qna_update to update comment content and load_replies to return rendered replies HTML. - UI/templates: add qna-form.php and qna-replies.php templates; update qna-card.php and qna-single.php to show/hide edit forms, wire up edit/delete actions, and adjust icon sizing/spacing. - Misc: small icon/spinner sizing and class tweaks for consistent UI. These changes let users edit their Q&A posts inline, update content via AJAX, and load reply lists dynamically for a smoother dashboard experience.
Rename and standardize discussion-replies APIs and templates to use 'comment' terminology. Changes: update frontend endpoint constant (LOAD_DISCUSSION_REPLIES -> LOAD_COMMENT_REPLIES), change AJAX action hook and handler in Lesson (tutor_load_discussion_replies -> tutor_load_comment_replies and load_discussion_replies() -> load_comment_replies()), normalize parameter names and validation messages (discussion_id -> comment_id), adjust response data passed to templates (use explicit array keys and remove unused lesson_comment), and update templates to use the provided user_id variable for permission checks. These edits improve naming consistency and data handling for comment replies.
Change SVG color in the button mixin from $tutor-icon-idle to $tutor-icon-secondary so button icons use the secondary icon token. This aligns icon styling with the updated design tokens while leaving hover/disabled behavior unchanged.
Update dashboard discussion templates to improve popover interactions and unify UI. Remove unused unread flag and add Alpine popover state to the comment card container; reply button now links to the single-comment view. Standardize popover menu items (added spacing class and explicit 20x20 icon sizes) across comment-card, comment-replies, and comment-single. Adjust popover wrapper markup for owner actions. Change comment form to use tutorForm mode 'onSubmit' and tweak layout (added tutor-sm-justify-end) for improved form behavior and alignment.
Update Q&A card buttons for solved and important actions: replace `tutor-btn-link` with `tutor-btn-ghost` for consistent styling, and tighten the `:disabled` binding so a button is only disabled when the mutation is pending for that specific action and question ID (prevents unrelated buttons from being disabled while an action is in progress). Changes applied in templates/dashboard/discussions/qna-card.php.
Introduce Alpine-based tooltips for the QnA action buttons (solved and important) by wrapping each button in tutorTooltip x-data, adding x-ref trigger/content, x-show/x-cloak transitions and localized x-text content. Adjust tooltip SCSS: reduce default max-width from 200px to 180px and set default text-align to center, while keeping large tooltips left-aligned. Replace direct current_user_id vs question->user_id checks with the $is_user_asker flag for clearer intent and reuse.
JS: Rename QnA mutations/handlers and add modal/URL param utilities (MODALS, URL_PARAMS). Introduce createQnAMutation/replyQnAMutation/deleteQnAMutation, handle form resets on success, add reloadReplies(order) to fetch and inject replies without full page reload, persist order in URL, add loadingReplies state and keyboard submit handler, and adjust delete flow to close modal and either reload replies or update URL. Templates: remove old flat qna-single.php and reorganize QnA templates under templates/learning-area/subpages/qna/: move qna-card.php, and add qna-form.php, qna-replies.php, qna-single.php. Update qna.php to load the new partials, use tutor_load_template for forms, update component name to "QnA", and wire ConfirmationModal to use deleteQnAMutation. Adjust popover/modal payload keys (question_id) and form IDs.
Use convertToErrorMessage for all mutation onError handlers to normalize toast error messages; import the util in the discussions page JS. Standardize modal payload keys to question_id (snake_case) and adjust hide/showModal ordering. Update Q&A form template: rename header, bump @SInCE, add configurable submit_label default and use it for the submit button, and clear default form_class. Update confirm handler in qna-list to pass payload to the mutation. Remove unused component imports in qna-replies and avoid rendering EmptyState in qna-single (redirect instead); replace direct user_id checks with is_user_asker. General cleanup and consistency fixes across discussion templates and frontend code.
Add an AJAX error handler in assets/src/js/v2/qna.js to parse server error payloads and display a tutor_toast on failures. Replace direct wp_send_json_error/wp_send_json_success calls in classes/Q_And_A.php with response_bad_request() and json_response(), and use tutor_utils()->error_message where appropriate to standardize API responses so the front-end can reliably handle and show error/success messages.
Stop constructing a new error object in the mutation catch block and assign the original thrown error (cast to TError) to the mutation state and callbacks. onError and onSettled now receive the original error instead of a pared-down object, preserving additional properties (e.g. stack or custom fields) for consumers. No behavior change otherwise; isError is still set and the error is rethrown.
Move the Q&A learning-area navigation item out of Template and into the Q_And_A class. Adds UrlHelper import, registers a filter (tutor_learning_area_sub_page_nav_item) and implements add_learning_area_menu() to inject the Q&A item conditionally (global setting, per-course enable flag, and user enrollment). Also unsets any existing 'qna' entry to avoid duplicates and removes the static qna entry from Template.php.
b-l-i-n-d
requested changes
Feb 16, 2026
b-l-i-n-d
approved these changes
Feb 17, 2026
QnA Refactored and edit delete options added
shewa12
approved these changes
Feb 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.