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

How can I put focus on the last element <Codemirror />? #619

Open
TigranGithub opened this issue Jan 18, 2024 · 3 comments
Open

How can I put focus on the last element <Codemirror />? #619

TigranGithub opened this issue Jan 18, 2024 · 3 comments

Comments

@TigranGithub
Copy link

for example clicking edit button and want to focus will be on last element.
Thanks!

@jaywcjlove
Copy link
Member

@TigranGithub I don't understand your exact need.

@HenryHengZJ
Copy link

HenryHengZJ commented Apr 30, 2024

@jaywcjlove here's an example:

1.) I have a custom UI that allow user to edit:
image

2.) When user click edit, I set the editable={true}, the component should has the blinking indicator placed at the last character. But instead the indicator displayed at the very first character

Expected:
image

Actual:
image

@jaywcjlove
Copy link
Member

@HenryHengZJ

<CodeMirror
    value={`console.log('hello')`}
    theme="none"
    height="400px !important"
    width="100%"
+    selection={EditorSelection.cursor(0)}
    style={{ margin: '0 0 23px 0', flex: 1 }}
    extensions={[langs.markdown()]}
/>

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

No branches or pull requests

3 participants