@remit/ui 0.0.110 → 0.0.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/ui",
3
- "version": "0.0.110",
3
+ "version": "0.0.112",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -371,9 +371,18 @@ const openDestinationTree = async (canvasElement: HTMLElement) => {
371
371
  await tick();
372
372
  };
373
373
 
374
- /** Opens a folder in the tree; tapping it both picks it and reveals its children. */
374
+ /**
375
+ * Opens a folder in the tree; tapping it both picks it and reveals its
376
+ * children. A tap toggles, and the branch holding the rule's current
377
+ * destination is already open when the tree appears, so a folder that is open
378
+ * is left alone rather than tapped shut.
379
+ */
375
380
  const openFolder = async (canvasElement: HTMLElement, label: string) => {
376
- clickAriaLabel(canvasElement, `Move to ${label}`);
381
+ const row = canvasElement.querySelector<HTMLElement>(
382
+ `[aria-label="Move to ${label}"]`,
383
+ );
384
+ if (!row) throw new Error(`no control labelled "Move to ${label}"`);
385
+ if (row.getAttribute("aria-expanded") !== "true") row.click();
377
386
  await tick();
378
387
  };
379
388
 
@@ -203,6 +203,27 @@ export const ExpandedRowComposed: StoryObj<typeof ExpandedMessage> = {
203
203
  ),
204
204
  };
205
205
 
206
+ /** The chevron beside the sender is the disclosure control, not a picture of
207
+ * one: press it to put the message away and press the row to bring it back.
208
+ * Reclaiming the space a long message takes is what a reader aims at it for. */
209
+ export const RowDisclosure: StoryObj<typeof ExpandedMessage> = {
210
+ render: function RowDisclosureRender() {
211
+ const [expanded, setExpanded] = useState(true);
212
+ return (
213
+ <div className="max-w-3xl border border-line">
214
+ {expanded ? (
215
+ <ExpandedMessage
216
+ message={row}
217
+ onHeaderClick={() => setExpanded(false)}
218
+ />
219
+ ) : (
220
+ <CollapsedMessage message={row} onClick={() => setExpanded(true)} />
221
+ )}
222
+ </div>
223
+ );
224
+ },
225
+ };
226
+
206
227
  /** The app owns the fetch and hands the row its state back; so does this. */
207
228
  const ThreadAttachments = () => {
208
229
  const [rows, setRows] = useState<AttachmentItem[]>([
@@ -184,7 +184,23 @@ export function ExpandedMessage({
184
184
  )}
185
185
  >
186
186
  <div className="flex items-start gap-3">
187
- <ChevronDown className="mt-1 size-3.5 shrink-0 text-fg-subtle" />
187
+ {/* The chevron is the disclosure control, not a picture of one: it is
188
+ what a reader aims at to put a message away, so it carries the
189
+ collapse itself rather than sitting beside the sender block that
190
+ does. */}
191
+ {onHeaderClick ? (
192
+ <button
193
+ type="button"
194
+ onClick={onHeaderClick}
195
+ aria-expanded={true}
196
+ aria-label="Collapse message"
197
+ className="mt-1 shrink-0 text-fg-subtle transition-colors hover:text-fg"
198
+ >
199
+ <ChevronDown className="size-3.5" />
200
+ </button>
201
+ ) : (
202
+ <ChevronDown className="mt-1 size-3.5 shrink-0 text-fg-subtle" />
203
+ )}
188
204
  <Avatar name={message.fromName} email={message.fromEmail} size="md" />
189
205
  <div className="min-w-0 flex-1">
190
206
  {onHeaderClick ? (
@@ -444,13 +444,23 @@ const AutoFocus = ({ caret }: { caret?: ComposeCaret }) => {
444
444
 
445
445
  useEffect(() => {
446
446
  if (!caret) return;
447
- const timer = setTimeout(
448
- () =>
449
- editor.focus(undefined, {
450
- defaultSelection: caret === "start" ? "rootStart" : "rootEnd",
451
- }),
452
- 0,
453
- );
447
+ // Seeding the document leaves a selection behind at the end of what was
448
+ // inserted, and `defaultSelection` only applies where there is none — so
449
+ // the caret is placed here rather than left to `focus`, which would open a
450
+ // new message below the signature instead of above it.
451
+ const timer = setTimeout(() => {
452
+ editor.update(
453
+ () => {
454
+ const root = $getRoot();
455
+ if (caret === "start") {
456
+ root.selectStart();
457
+ return;
458
+ }
459
+ root.selectEnd();
460
+ },
461
+ { onUpdate: () => editor.focus() },
462
+ );
463
+ }, 0);
454
464
  return () => clearTimeout(timer);
455
465
  }, [editor, caret]);
456
466