slate-angular 19.1.1 → 19.1.2

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.
@@ -3852,6 +3852,17 @@ const defaultScrollSelectionIntoView = (editor, domRange) => {
3852
3852
  // so enabled only if the selection has been collapsed.
3853
3853
  if (domRange.getBoundingClientRect && (!editor.selection || (editor.selection && Range.isCollapsed(editor.selection)))) {
3854
3854
  const leafEl = domRange.startContainer.parentElement;
3855
+ // COMPAT: In Chrome, domRange.getBoundingClientRect() can return zero dimensions for valid ranges (e.g. line breaks).
3856
+ // When this happens, do not scroll like most editors do.
3857
+ const domRect = domRange.getBoundingClientRect();
3858
+ const isZeroDimensionRect = domRect.width === 0 && domRect.height === 0 && domRect.x === 0 && domRect.y === 0;
3859
+ if (isZeroDimensionRect) {
3860
+ const leafRect = leafEl.getBoundingClientRect();
3861
+ const leafHasDimensions = leafRect.width > 0 || leafRect.height > 0;
3862
+ if (leafHasDimensions) {
3863
+ return;
3864
+ }
3865
+ }
3855
3866
  leafEl.getBoundingClientRect = domRange.getBoundingClientRect.bind(domRange);
3856
3867
  scrollIntoView(leafEl, {
3857
3868
  scrollMode: 'if-needed'