Fix Share access, initials, copy confirm, and mailed export links #112

Merged
an.di merged 5 commits from adilallo/fix/share-dialog into main 2026-11-22 23:35:14 +00:00
Member

Overview

Share was hard to use on a phone: the “Who can read” menu was clipped so “Anyone with the link” could not be picked, avatar initials disappeared on the yellow fill, and Copy failed silently when the clipboard was denied. Dead share URLs still returned a page, mailed export links never expired, and failed /r/ lookups were not limited.

This change makes the access menu usable with mouse, touch, and keyboard, shows initials and a readable link with a copy confirmation, and adds a content security policy plus expiring export tokens.

Changes

  • Portal the Share access listbox to document.body and open it above the trigger when there is no room below, so both options stay on screen. Arrow / Home / End / Enter / Space move through the list. Options are at least 44px on phones. Escape stays inside the menu.
  • Filled avatars use dark initials on the yellow fill. The share URL is a read-only field (not a dimmed disabled input). Copy confirms with “Link copied” and a “Copied” button, with an execCommand fallback. Invite and Copy stay outline, not grey-disabled, when the email field is empty. A missing /r/[slug] returns 404.
  • Send a Content-Security-Policy (self, optional Umami origin, inline styles). Drop X-Powered-By. Mailed export links carry an expiry and a version; turning share off or removing a reader rotates the version so old mail stops working. Failed public share lookups are rate-limited before the database query.
  • On a short window the people list scrolls instead of squashing the two avatar rows. The pane uses the same scrollbar-design class as Create and Dialog.

Screenshots

01-share-initials-and-outline-buttons.png

How to Test

  1. npm run storybook → Components / Modals / Share (Default and Anyone with the Link).
  2. At 320, 390, 640, and 1280, open “Who can read this Rule” and pick Anyone with the link with mouse/touch. Both options must be fully visible and tappable.
  3. Keyboard: open the menu, Arrow Up/Down, Home/End, Enter or Space to choose, Escape to close without leaving the dialog.
  4. Confirm initials are readable on the yellow avatars. With a public link on, the URL is white-on-dark and selectable. Copy shows Link copied and the button Copied (try with clipboard denied).
  5. Open a garbage /r/… slug and confirm a 404, not a titled empty page.
  6. After npm run migrate:smoke, turn share off or remove a reader and confirm an old mailed export URL no longer downloads. Check response headers for CSP and no X-Powered-By.

Notes

  • Export-token TTL in code is seven days. Tokens rotate when share is turned off or a reader is removed.
  • Share slug length is unchanged; brute-force is handled with a miss rate limit instead.
  • CSP / token / rate-limit work has no UI. The gray track on a short-frame scrollbar is the shared scrollbar-design gutter (same as Create and Dialog); Figma’s scrollbar asset is only the 6px thumb.
  • The last Changes bullet (short-frame people list + scrollbar-design) is still unstaged on Share.view.tsx and Share.test.tsx until you commit it.02-share-access-menu-open.png03-share-readable-link-field.png04-share-link-copied-confirmation.png05-share-phone-390-outline-buttons.png
## Overview Share was hard to use on a phone: the “Who can read” menu was clipped so “Anyone with the link” could not be picked, avatar initials disappeared on the yellow fill, and Copy failed silently when the clipboard was denied. Dead share URLs still returned a page, mailed export links never expired, and failed `/r/` lookups were not limited. This change makes the access menu usable with mouse, touch, and keyboard, shows initials and a readable link with a copy confirmation, and adds a content security policy plus expiring export tokens. ## Changes - Portal the Share access listbox to `document.body` and open it above the trigger when there is no room below, so both options stay on screen. Arrow / Home / End / Enter / Space move through the list. Options are at least 44px on phones. Escape stays inside the menu. - Filled avatars use dark initials on the yellow fill. The share URL is a read-only field (not a dimmed disabled input). Copy confirms with “Link copied” and a “Copied” button, with an `execCommand` fallback. Invite and Copy stay outline, not grey-disabled, when the email field is empty. A missing `/r/[slug]` returns 404. - Send a Content-Security-Policy (self, optional Umami origin, inline styles). Drop `X-Powered-By`. Mailed export links carry an expiry and a version; turning share off or removing a reader rotates the version so old mail stops working. Failed public share lookups are rate-limited before the database query. - On a short window the people list scrolls instead of squashing the two avatar rows. The pane uses the same `scrollbar-design` class as Create and Dialog. ## Screenshots ![01-share-initials-and-outline-buttons.png](attachments/fceeba56-fa33-4333-9168-ac4dab4c25e9) ## How to Test 1. `npm run storybook` → Components / Modals / Share (Default and Anyone with the Link). 2. At 320, 390, 640, and 1280, open “Who can read this Rule” and pick **Anyone with the link** with mouse/touch. Both options must be fully visible and tappable. 3. Keyboard: open the menu, Arrow Up/Down, Home/End, Enter or Space to choose, Escape to close without leaving the dialog. 4. Confirm initials are readable on the yellow avatars. With a public link on, the URL is white-on-dark and selectable. Copy shows **Link copied** and the button **Copied** (try with clipboard denied). 5. Open a garbage `/r/…` slug and confirm a 404, not a titled empty page. 6. After `npm run migrate:smoke`, turn share off or remove a reader and confirm an old mailed export URL no longer downloads. Check response headers for CSP and no `X-Powered-By`. ## Notes - Export-token TTL in code is seven days. Tokens rotate when share is turned off or a reader is removed. - Share slug length is unchanged; brute-force is handled with a miss rate limit instead. - CSP / token / rate-limit work has no UI. The gray track on a short-frame scrollbar is the shared `scrollbar-design` gutter (same as Create and Dialog); Figma’s scrollbar asset is only the 6px thumb. - The last Changes bullet (short-frame people list + `scrollbar-design`) is still unstaged on `Share.view.tsx` and `Share.test.tsx` until you commit it.![02-share-access-menu-open.png](attachments/d3f71a9c-9fe6-40c3-91ff-3cf113cfa1e4)![03-share-readable-link-field.png](attachments/2456d21c-6bb3-4040-adc0-60cead185836)![04-share-link-copied-confirmation.png](attachments/dc9b12a6-2e91-414b-974d-b8d3320a0f5d)![05-share-phone-390-outline-buttons.png](attachments/642ce5c3-6e8f-4e1e-8d7a-65158ba865ca)
an.di added 5 commits 2026-11-22 23:34:58 +00:00
The listbox was clipped inside the sheet, sat at 24px, and ignored arrow keys, so Anyone with the link could not be chosen by mouse or touch.
Filled avatars used white ink on yellow, the link field was a dimmed disabled input, and Copy failed silently when the clipboard API was denied.
Responses had no CSP, the 48-hour download token never changed, and short share slugs could be guessed without a miss limit.
Overflow-hidden let flex shrink the avatar rows, and the pane used the browser scrollbar instead of the design-system one.
an.di merged commit 600056499c into main 2026-11-22 23:35:14 +00:00
an.di deleted branch adilallo/fix/share-dialog 2026-11-22 23:35:16 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: CommunityRule/community-rule#112