Skip to content

fix(attachments): show Add button as icon-only on tablet and mobile#3258

Draft
moconnell9 wants to merge 2 commits into
openmrs:mainfrom
moconnell9:fix/attachment-upload
Draft

fix(attachments): show Add button as icon-only on tablet and mobile#3258
moconnell9 wants to merge 2 commits into
openmrs:mainfrom
moconnell9:fix/attachment-upload

Conversation

@moconnell9
Copy link
Copy Markdown

@moconnell9 moconnell9 commented Apr 22, 2026

Requirements

Summary

Two bugs fixed in the Attachments widget:

1. Upload modal buttons missing on mobile/tablet
The Cancel and "Add attachment" submit buttons in the upload modal
(file-review.component.tsx) were wrapped in <UserHasAccess privilege="Create Attachments">.
Because UserHasAccess renders null on its first render (before the session
observable emits), the buttons were invisible on mobile/tablet devices where
slower networks mean the session hasn't loaded by the time the modal opens.
A user who has already passed the entry-point privilege check to open the
modal should never have their in-modal controls hidden.

Fix: removed UserHasAccess from inside the modal footer. The privilege
check is now correctly placed at the two entry points that open the modal
(the Add button in the CardHeader and the EmptyState launch button).

2. Add button not visible on tablet/phone viewports
The CardHeader Add button was always rendered as text+icon regardless of
screen size, causing it to be clipped or missing on smaller viewports.

Fix: use isDesktop(useLayoutType()) to render the button as icon-only
(hasIconOnly) on non-desktop viewports, matching the Carbon Design System
pattern used elsewhere in the app.

Screenshots

Related Issue

N/A

Other

The root cause of the modal button bug (first-render null in UserHasAccess)
is fixed upstream in a companion PR against openmrs-esm-core. This PR
fixes the symptom by moving the privilege gate to the correct location
regardless.

@moconnell9 moconnell9 force-pushed the fix/attachment-upload branch from c8cee74 to 9191419 Compare April 22, 2026 21:42
The Add attachment button was clipped/invisible on tablet and phone
viewports because the ContentSwitcher (md size) + divider + button text
overflowed the constrained CardHeader width. Use hasIconOnly on tablet
and phone layouts so the button renders as just the icon, which fits.
@moconnell9 moconnell9 force-pushed the fix/attachment-upload branch from 9191419 to 7a4ebbd Compare April 22, 2026 22:04
…ints

The Cancel and Add Attachment buttons were both wrapped in a single
UserHasAccess privilege="Create Attachments" check inside the upload
modal. UserHasAccess renders null until the session response arrives
from /ws/rest/v1/session — on slow mobile networks this can take
hundreds of milliseconds, and on backends where webservices.rest fails
to load, it never resolves. In both cases the entire ModalFooter goes
blank with no way to complete or dismiss the upload.

Fix: remove the privilege check from the modal footer so both buttons
are always visible once the modal is open. Gate the entry points
instead — the Add button in the CardHeader and the EmptyState launchForm
are now wrapped in UserHasAccess, so users without the privilege cannot
open the modal in the first place.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant