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

feat: Added a focus parameter to the setMarkdown and setHTML functions #2030

Closed
wants to merge 2 commits into from
Closed

feat: Added a focus parameter to the setMarkdown and setHTML functions #2030

wants to merge 2 commits into from

Conversation

azmeuk
Copy link
Contributor

@azmeuk azmeuk commented Nov 19, 2021

#1772 introduced a focus parameter to the moveCursorToEnd function.

Now I encounter the need to not take the focus when setting markdown in the editor, hence I added a focus parameter to the setMarkdown and setHTML functions, defaulted to true, that is passed to moveCursorToEnd.

The autofocus parameter introduced in #1772 is also passed to setMarkdown or setHTML during the editor constructor to ensure cursor is not taken by the editor if autofocus is false. I think this may help with #1945 and #1802, because without this patch, if the editor is initialized with data it still takes the focus.

I am not really sure how to test this so I did not write any, but please let me know if you think this is important.

ping @js87zz

@azmeuk azmeuk changed the title feat: Added a focus parameter to the setMarkdown function feat: Added a focus parameter to the setMarkdown and setHTML functions Nov 20, 2021
@azmeuk
Copy link
Contributor Author

azmeuk commented Dec 6, 2021

@js87zz any chance that you might review this soon? Thank you in advance!

@js87zz
Copy link
Contributor

js87zz commented Dec 10, 2021

@azmeuk
I'm sorry for the late response. First of all, I haven't considered adding the parameter to solve this issue, so I'm testing internally to see if there's a better way. I'll review it more and comment further. Thank you!

@seanwang1998
Copy link

@js87zz I'm currently using v3.1.0, setting autofocus to false, and still stealing focus after creating the Editor
image

@js87zz
Copy link
Contributor

js87zz commented Dec 14, 2021

@azmeuk
I confirmed that autofocus is ignored only in markdown tab mode. Since there is the PR(#2085) for this, the problem can be resolved.
In addition, since users can control the focus through the cursorToEnd parameter in setMarkdown(or setHTML) API, it seems that there is no need to add parameter for this.
So unfortunately, the PR will not be merged. Thank you so much for taking the time to help resolve our issues. The autofocus option you added was very helpful to users. Thank you :)👍

@azmeuk
Copy link
Contributor Author

azmeuk commented Dec 14, 2021

No problem. As long as the bug gets fixed in the end. 👍

@azmeuk azmeuk closed this Dec 14, 2021
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.

3 participants