AppFlowy-IO / AppFlowy-IO/appflowy-editor
[Bug] Wrong variable in EditorState.getNodeInOffset() function in selection service
- Dominant language
- Dart
- Stars
- 684
- Forks
- 329
- PR merge metrics
- No merged PRs in 30d
Description
### Bug Description
Bug found during implementation of custom blocks postioned horizontally.
[Source Line 51-58 of shared.dart](https://github.com/AppFlowy-IO/appflowy-editor/blob/680ada4fd865b1c0bcdba1b673621a8301eeb146/lib/src/editor/editor_component/service/selection/shared.dart#L51-L58)
```
final filteredNodes = List.of(sortedNodes)
..retainWhere((n) => n.rect.bottom == sortedNodes[min].rect.bottom);
min = 0;
if (filteredNodes.length > 1) {
min = _findCloseNode(
sortedNodes,
0,
filteredNodes.length - 1,
(rect) => rect.right <= offset.dx,
);
}
```
should be: filteredNodes instead of sortedNodes.
``` final filteredNodes = List.of(sortedNodes)
..retainWhere((n) => n.rect.bottom == sortedNodes[min].rect.bottom);
min = 0;
if (filteredNodes.length > 1) {
min = _findCloseNode(
filteredNodes,
0,
filteredNodes.length - 1,
(rect) => rect.right <= offset.dx,
);
}
```
### How to Reproduce
Keep 3 paragraphNodes() in a row. While attempting to select the middle one, selection shifts to 3rd node.
### Expected Behavior
Selection cursor to be on the middle node
### Operating System
Windows 11
### AppFlowy Editor Version(s)
2.3.4
### Screenshots
_No response_
### Additional Context
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.