Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix-test-types
Browse files Browse the repository at this point in the history
  • Loading branch information
etrepum committed Apr 29, 2024
2 parents d86e33a + 02ec0bb commit e7aac52
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 7 deletions.
30 changes: 30 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--
Title format should be:
[Affected Packages] PR Type: title
Example:
[lexical-playground][lexical-link] Feature: Add more emojis
Choose from the following PR Types:
Breaking change / Refactor / Feature / Bug Fix / Documentation Update / Chore
-->

## Description
<!--
- What is the current behavior that you are modifying?
- What are the behavior or changes that are being added by this PR?
-->
*Describe the changes in this pull request*

**Closes:** #<!-- issue number -->

## Test plan

### Before

*Insert relevant screenshots/recordings/automated-tests*


### After

*Insert relevant screenshots/recordings/automated-tests*
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import {
invariant,
TestComposer,
} from 'lexical/src/__tests__/utils';
import * as React from 'react';
import {createRoot} from 'react-dom/client';
import * as ReactTestUtils from 'react-dom/test-utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
TextNode,
} from 'lexical';
import {createTestEditor} from 'lexical/src/__tests__/utils';
import * as React from 'react';
import {createRef, useEffect, useMemo} from 'react';
import {createRoot, Root} from 'react-dom/client';
import * as ReactTestUtils from 'react-dom/test-utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
import {TableCellNode, TableNode, TableRowNode} from '@lexical/table';
import {LexicalEditor} from 'lexical';
import {initializeClipboard, TestComposer} from 'lexical/src/__tests__/utils';
import * as React from 'react';
import {createRoot} from 'react-dom/client';
import * as ReactTestUtils from 'react-dom/test-utils';

Expand Down
16 changes: 13 additions & 3 deletions packages/lexical/src/LexicalSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1912,6 +1912,7 @@ function internalResolveSelectionPoint(
// We use the anchor to find which child node to select
const childNodes = dom.childNodes;
const childNodesLength = childNodes.length;
const blockCursorElement = editor._blockCursorElement;
// If the anchor is the same as length, then this means we
// need to select the very last text node.
if (resolvedOffset === childNodesLength) {
Expand All @@ -1920,11 +1921,20 @@ function internalResolveSelectionPoint(
}
let childDOM = childNodes[resolvedOffset];
let hasBlockCursor = false;
if (childDOM === editor._blockCursorElement) {
if (childDOM === blockCursorElement) {
childDOM = childNodes[resolvedOffset + 1];
hasBlockCursor = true;
} else if (editor._blockCursorElement !== null) {
resolvedOffset--;
} else if (blockCursorElement !== null) {
const blockCursorElementParent = blockCursorElement.parentNode;
if (dom === blockCursorElementParent) {
const blockCursorOffset = Array.prototype.indexOf.call(
blockCursorElementParent.children,
blockCursorElement,
);
if (offset > blockCursorOffset) {
resolvedOffset--;
}
}
}
resolvedNode = getNodeFromDOM(childDOM);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
html,
TestComposer,
} from 'lexical/src/__tests__/utils';
import * as React from 'react';
import {createRoot, Root} from 'react-dom/client';
import * as ReactTestUtils from 'react-dom/test-utils';

Expand Down

0 comments on commit e7aac52

Please sign in to comment.