-
Notifications
You must be signed in to change notification settings - Fork 54
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
Pan / Zoom is blocking <input> in foreignObject #99
Comments
Mh, that's a tough one. Ofc the default behavior needs to be prevented so that the browser is not scrolling or zooming. |
Thank you. // Get the foreignElement's input (here the input is wrapped in a <div>)
const input: HTMLInputElement = foreignElement.node.getElementsByTagName('input')[0];
// The listener for 'click outside'
const onClickOutside = (event: MouseEvent) => {
if (event.target === input) {
return false;
}
// Blur the inner input element.
input.blur();
// Remove the listener on window
window.removeEventListener('mousedown', onClickOutside);
};
// Add listener to mousedown event
input.addEventListener('mousedown', () => {
input.focus();
// Add listener to 'click outside' event
window.addEventListener('mousedown', onClickOutside);
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello and thank you for this work!
I have an issue on inserting an HTML
<input type="text" />
in aforeignObject
: the HTML input doesn't take focus.I guess the plugin listeners are having precedence over the input's one...
Any advice to resolve this?
Thank you.
The text was updated successfully, but these errors were encountered: