From f58f08a40d498feaed4020acbebc3a4c7a202d31 Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Wed, 5 Aug 2026 17:07:26 +0530 Subject: [PATCH] fix: prevent avatar upload overlay from showing in conversation list (#15332) # Pull Request Template ## Description This PR fixed the conversation list was incorrectly rendering the avatar upload overlay on every conversation card, even though uploads aren't supported there. Clicking it could throw a `TypeError: Cannot read properties of null (reading 'click')`. Conversation cards now only show the selection checkbox, while avatar uploads continue to work everywhere they're supported. ### Cause `ConversationCard` always passed the `#overlay` slot, but the checkbox inside it was wrapped in `v-if`. When the checkbox wasn't rendered, Vue treated the slot as empty and fell back to the default upload overlay from `Avatar`. That overlay's click handler expects a file input, but the file input is only rendered when `allowUpload` is enabled. Since conversation cards never enable uploads, clicking the overlay could dereference a null file input and throw. ### How to reproduce This isn't reliably reproducible manually. It only happens when the upload overlay becomes visible while the card's internal hover state is out of sync with the browser's CSS `:hover` state. In normal interaction, entering the card immediately updates the hover state and shows the checkbox instead, so the issue effectively self-recovers. The new test reproduces this state directly and verifies the fix. ## What changed * Moved `v-if="allowUpload"` from the hidden file input to the upload overlay itself, so the overlay and file input are always mounted together. * Added `Avatar.spec.js` coverage for the overlay slot, including the empty-slot case that triggered this bug, along with the existing upload, delete, badge, sizing, initials, and image fallback behavior. Fixes https://linear.app/chatwoot/issue/CW-7726/typeerror-cannot-read-properties-of-null-reading-click https://chatwoot-p3.sentry.io/issues/7291677410/?project=4507182691975168&referrer=Linear ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? ### Screenshots **Before** image **After** image ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules --- .../components-next/avatar/Avatar.vue | 2 +- .../avatar/specs/Avatar.spec.js | 334 ++++++++++++++++++ 2 files changed, 335 insertions(+), 1 deletion(-) create mode 100644 app/javascript/dashboard/components-next/avatar/specs/Avatar.spec.js diff --git a/app/javascript/dashboard/components-next/avatar/Avatar.vue b/app/javascript/dashboard/components-next/avatar/Avatar.vue index c98c8d43a..8d47649d2 100644 --- a/app/javascript/dashboard/components-next/avatar/Avatar.vue +++ b/app/javascript/dashboard/components-next/avatar/Avatar.vue @@ -280,6 +280,7 @@ watch( :handle-image-upload="handleImageUpload" >