@expensify/react-native-live-markdown 0.1.114 → 0.1.116

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.
@@ -145,18 +145,30 @@ function scrollCursorIntoView(target: HTMLInputElement) {
145
145
  return;
146
146
  }
147
147
 
148
- const caretRect = selection.getRangeAt(0).getClientRects()[0];
148
+ const caretRects = selection.getRangeAt(0).getClientRects();
149
+
150
+ // we'll find the caretRect from the DOMRectList above with the largest bottom value
151
+ let currentCaretRect = caretRects[0];
152
+ if (currentCaretRect) {
153
+ for (let i = 1; i < caretRects.length; i++) {
154
+ const caretRect = caretRects[i];
155
+ if (caretRect && caretRect.bottom > currentCaretRect.bottom) {
156
+ currentCaretRect = caretRect;
157
+ }
158
+ }
159
+ }
160
+
149
161
  const editableRect = target.getBoundingClientRect();
150
162
 
151
163
  // Adjust for padding and border
152
164
  const paddingTop = parseFloat(window.getComputedStyle(target).paddingTop);
153
165
  const borderTop = parseFloat(window.getComputedStyle(target).borderTopWidth);
154
166
 
155
- if (caretRect && !(caretRect.top >= editableRect.top + paddingTop + borderTop && caretRect.bottom <= editableRect.bottom - 2 * (paddingTop - borderTop))) {
156
- const topToCaret = caretRect.top - editableRect.top;
167
+ if (currentCaretRect && !(currentCaretRect.top >= editableRect.top + paddingTop + borderTop && currentCaretRect.bottom <= editableRect.bottom - 2 * (paddingTop - borderTop))) {
168
+ const topToCaret = currentCaretRect.top - editableRect.top;
157
169
  const inputHeight = editableRect.height;
158
170
  // Chrome Rects don't include padding & border, so we're adding them manually
159
- const inputOffset = caretRect.height - inputHeight + paddingTop + borderTop + (BrowserUtils.isChromium ? 0 : 4 * (paddingTop + borderTop));
171
+ const inputOffset = currentCaretRect.height - inputHeight + paddingTop + borderTop + (BrowserUtils.isChromium ? 0 : 4 * (paddingTop + borderTop));
160
172
 
161
173
  target.scrollTo(0, topToCaret + target.scrollTop + inputOffset);
162
174
  }