fix(attachments): show Add button as icon-only on tablet and mobile#3258
Draft
moconnell9 wants to merge 2 commits into
Draft
fix(attachments): show Add button as icon-only on tablet and mobile#3258moconnell9 wants to merge 2 commits into
moconnell9 wants to merge 2 commits into
Conversation
c8cee74 to
9191419
Compare
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.
9191419 to
7a4ebbd
Compare
…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>
c3fefed to
32f4cbc
Compare
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.
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
UserHasAccessrenders null on its first render (before the sessionobservable 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
UserHasAccessfrom inside the modal footer. The privilegecheck 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 Systempattern 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 PRfixes the symptom by moving the privilege gate to the correct location
regardless.