Skip to content

Note: check e.relatedTarget before setting editing: false #2894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ethan-james
Copy link
Collaborator

Fixes #2841

The editing({ value: false }) action was being dispatched when focus was moved from the note to the thought. I think it must be possible for selection.isActive() to be false onBlur before onFocus runs on the thought that is getting selected.

More testing is required to verify this assertion a little better, and also to ensure that e.relatedTarget is an acceptable substitute for selection.isActive(). There are some events that may fire with a value in e.relatedTarget such as opening the hamburger menu, but basic testing indicates that this works OK.

@ethan-james ethan-james marked this pull request as draft April 17, 2025 19:32
@ethan-james ethan-james marked this pull request as draft April 17, 2025 19:32
@ethan-james
Copy link
Collaborator Author

@raineorshine Can you please test this branch to see if it resolves #2840 as well as #2841? It's not too terribly likely that the two are directly related, but I have difficulty reproducing #2840 and it would be good to know.

@raineorshine
Copy link
Contributor

Let me know if you still need me to test this against both issues, since we clarified the steps to reproduce.

@ethan-james
Copy link
Collaborator Author

Let me know if you still need me to test this against both issues, since we clarified the steps to reproduce.

That's OK, I verified that this does not fix #2840.

@ethan-james ethan-james marked this pull request as ready for review April 18, 2025 18:40
@ethan-james
Copy link
Collaborator Author

I copied over the relatedTarget logic from Editable, which covers the same cases and should be pretty well battle-tested.

Copy link
Contributor

@raineorshine raineorshine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful, thanks!

@@ -272,4 +274,22 @@ describe('mobile only', () => {
const focusNode = await getSelection().focusNode
expect(focusNode).toBeUndefined()
})

describe('when caret moves from inside a note', () => {
it('cursorForward should move the cursor to the next thought', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test confirmed ✓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[iOS] Caret does not move on second tap after note
2 participants