Skip to content
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

Update editable.tsx: auto-focus fix for end of line with several chil… #4695

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

Conversation

GrinchakAndrew
Copy link

Solution resolves cursor position in the Editor with autofocus set to true, when cursor pos is 0 instead of end of line.

…dren for input div

Update editable.tsx: auto-focus fix for end of line with several children for input div
@changeset-bot
Copy link

changeset-bot bot commented Nov 27, 2021

⚠️ No Changeset found

Latest commit: 6f2e342

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

if (ref.current && autoFocus) {
if(window.getSelection && document.createRange) {
const range = document.createRange();
node.focus();
Copy link

Choose a reason for hiding this comment

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

what is node?

Copy link
Author

Choose a reason for hiding this comment

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

@akonsu Sorry, node was a reference to ref.current in my other sandbox. Will correct it now.

Copy link
Collaborator

@dylans dylans left a comment

Choose a reason for hiding this comment

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

Looks reasonable. Please add a changeset when you have a moment and then we can land this.

if (ref.current && autoFocus) {
if(window.getSelection && document.createRange) {
const range = document.createRange();
ref.current.focus();
Copy link

@akonsu akonsu Dec 5, 2021

Choose a reason for hiding this comment

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

Is it essential to call ref.current.focus() here and not at the end of this if clause? Maybe we can move this call out of the if statement (from both this clause and the else clause)?

}
}, [autoFocus])
if (ref.current && autoFocus) {
if(window.getSelection && document.createRange) {
Copy link

Choose a reason for hiding this comment

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

Please prettify the diff. This if needs a space after it.

@dylans
Copy link
Collaborator

dylans commented Jan 11, 2022

@GrinchakAndrew any chance you have time to wrap this one up. It looks like it needs a linting fix and there are a couple of comments to address. Thanks!

@GrinchakAndrew
Copy link
Author

packages/slate-react/src/components/editable.tsx

Hello, i am afkb for the time being. No need to run linting on the whole project. Pls., add it to one line of code.

@dylans
Copy link
Collaborator

dylans commented Jan 11, 2022

packages/slate-react/src/components/editable.tsx

Hello, i am afkb for the time being. No need to run linting on the whole project. Pls., add it to one line of code.

Unfortunately because you created your PR from your main branch it's not easy to clone your PR locally. But I'll make it work.

* Run prettier
* Null checks for selection
Copy link
Collaborator

@dylans dylans left a comment

Choose a reason for hiding this comment

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

This change is causing a regression in the markdown-shortcuts example and is thus failing our integrations tests. Will look when I get a chance, unless someone else has time to track this down before I do.

@JustinBeaudry
Copy link

JustinBeaudry commented Mar 23, 2022

Andrew lives in Ukraine so I know he won't be able to finish this anytime soon. We discovered this issue on a project together so I'll get this to the finish line.

Looks like code-highlighting.ts and markdown-shortcuts.ts are both failing. I'm taking a look, but am unable to run the cypress tests locally. Is there a recommended node version or caveat to getting it to run locally? (Using node v14.17.6 and OS Ubuntu 20.04)

@dylans
Copy link
Collaborator

dylans commented Mar 27, 2022

Is there a recommended node version or caveat to getting it to run locally? (Using node v14.17.6 and OS Ubuntu 20.04)

Hi @JustinBeaudry, thanks, I hope @GrinchakAndrew is ok.

With respect to running locally, they run for me with 14.15.5 on macOS, but there's nothing special about that version. If they won't run locally you can commit to the PR which will trigger a re-run which is not ideal but better than nothing. Feel free to ping me on Slack ( https://join.slack.com/t/slate-js/shared_invite/zt-f8t986ip-7dA1DyiqPpzootz1snKXkw ) if you're stuck.

@dylans
Copy link
Collaborator

dylans commented Oct 4, 2023

My attempt at using GitHub's tooling to resolve merge conflicts failed badly here. I will look at this later.

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.

4 participants