-
Notifications
You must be signed in to change notification settings - Fork 16
Delegate the focus inside the text editor #3304
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
Conversation
|
Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-3304/ |
civing
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to let the consumer decide when to set focus and how. I'm not sure we always want to set the focus back to the text editor when we have a stopTrigger event. It should be up to the consumer
Should we instead have a specific |
Does it work to override the focus() method in |
The setFocus function on the I could try ref forwarding from the |
I tried to override the public focus method and it works great. I'm not sure if this is the most canonical way of doing it though. But it is simple and works 😄 Screen.Recording.2024-11-19.at.18.02.17.movlimel-text-editor connectedCallback() {
this.host.focus = this.focus.bind(this);
}
return [
<limel-prosemirror-adapter
ref={(el) =>
(this.prosemirrorAdapter =
el as HTMLLimelProsemirrorAdapterElement)
}
aria-placeholder={this.placeholder}
contentType={this.contentType}
onChange={this.handleChange}
customElements={this.customElements}
value={this.value}
aria-controls={this.helperTextId}
id={this.editorId}
tabindex={this.disabled ? -1 : undefined}
aria-disabled={this.disabled}
language={this.language}
triggerCharacters={this.triggers}
/>,
this.renderPlaceholder(),
this.renderHelperLine(),
];limel-prosemirror-adatpor public connectedCallback() {
if (this.view) {
this.initializeTextEditor();
}
this.host.addEventListener(
'open-editor-link-menu',
this.handleOpenLinkMenu,
);
this.host.focus = this.focus.bind(this);
}
public focus() {
console.log('Focus is great!');
this.view?.focus();
} |
c82e58d to
b9784ed
Compare
|
@civing I've dropped the stopTrigger function completely for now - it's easy to implement if we need it. I've added ref forwarding so we can access the focus function on the I'm not sure about this approach though.
My personal preference would be to have our own event, have the consumer trigger it by adding an interface, it could be in it's own very small plugin, and when that function is called it sends the event that the |
b9784ed to
36d30f0
Compare
36d30f0 to
4e28a35
Compare
Makes sure to delegate the focus to prosemirror if the text editor get's the focus.
b5fa744 to
9797f0c
Compare
|
🎉 This PR is included in version 37.70.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Fixes: https://github.com/Lundalogik/crm-feature/issues/4476
This uses ref forwarding to override the default focus method allowing a consumer to set focus on the prosemirror editor view.