slate-react 0.116.0 → 0.117.1

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.
@@ -7487,6 +7487,18 @@
7487
7487
  // so enabled only if the selection has been collapsed.
7488
7488
  if (domRange.getBoundingClientRect && (!editor.selection || editor.selection && slate.Range.isCollapsed(editor.selection))) {
7489
7489
  var leafEl = domRange.startContainer.parentElement;
7490
+ // COMPAT: In Chrome, domRange.getBoundingClientRect() can return zero dimensions for valid ranges (e.g. line breaks).
7491
+ // When this happens, do not scroll like most editors do.
7492
+ var domRect = domRange.getBoundingClientRect();
7493
+ var isZeroDimensionRect = domRect.width === 0 && domRect.height === 0 && domRect.x === 0 && domRect.y === 0;
7494
+ if (isZeroDimensionRect) {
7495
+ var leafRect = leafEl.getBoundingClientRect();
7496
+ var leafHasDimensions = leafRect.width > 0 || leafRect.height > 0;
7497
+ if (leafHasDimensions) {
7498
+ return;
7499
+ }
7500
+ }
7501
+ // Default behavior: use domRange's getBoundingClientRect
7490
7502
  leafEl.getBoundingClientRect = domRange.getBoundingClientRect.bind(domRange);
7491
7503
  e(leafEl, {
7492
7504
  scrollMode: 'if-needed'