@remit/ui 0.0.119 → 0.0.120

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.119",
3
+ "version": "0.0.120",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -177,6 +177,20 @@ const characters = (): Node => {
177
177
  return leaf;
178
178
  };
179
179
 
180
+ /**
181
+ * jsdom lays out nothing and moves no caret, so a selection Lexical set on its
182
+ * own — `select()`, or an edit that carries the caret with it — lives only in
183
+ * Lexical's own state. The next commit reconciles against the document's
184
+ * selection, finds none, and puts the anchor back at the start. Everything
185
+ * about a withheld mark is read off the caret at paint time, so a test that
186
+ * left the browser's selection behind is asserting on whichever landed first:
187
+ * the answer to the check, or the reconciliation that undoes the caret. The
188
+ * browser is the one that does this; here the test has to.
189
+ */
190
+ const putCaret = (offset: number): void => {
191
+ dom.window.document.getSelection()?.setPosition(characters(), offset);
192
+ };
193
+
180
194
  /**
181
195
  * The desktop popover portals to the document body, clear of whatever
182
196
  * ancestor would otherwise clip it, so the menu and its rows are found
@@ -217,7 +231,7 @@ const pressDownAt = async (
217
231
  pointerType: string,
218
232
  button = 0,
219
233
  ): Promise<void> => {
220
- dom.window.document.getSelection()?.setPosition(characters(), offset);
234
+ putCaret(offset);
221
235
  await act(async () => {
222
236
  editable().dispatchEvent(
223
237
  pointerEvent("pointerdown", pointerType, {
@@ -268,6 +282,7 @@ const caretAt = async (
268
282
  text?.select(offset, offset);
269
283
  });
270
284
  });
285
+ putCaret(offset);
271
286
  };
272
287
 
273
288
  /** A key on the writing surface, whatever it turns out to do. */
@@ -745,6 +760,7 @@ describe("the correction menu", () => {
745
760
  text?.spliceText(18, 0, "y", true);
746
761
  });
747
762
  });
763
+ putCaret(19);
748
764
  await settle();
749
765
 
750
766
  assert.equal(editable().textContent, "Ths report is redyy today");