-
-
Notifications
You must be signed in to change notification settings - Fork 169
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
Can not include multiple keyboards in an Angular component #50
Comments
Hey @ddahan, You need to give a different class to each keyboard instance, otherwise the second instance will just override the first one. For example:
Docs: Demo: This should fix your issue, but if it doesn't let me know and we can look at this further. Regards, |
Hi @hodgef and thanks for quick reply (and for your amazing job on this). I understand that there is a conflict between 2 keyboards and I think I understood your code samples. However, in Angular, the clean way to work when you want to use the same stuff several times is to create a unique component (this is what I did with Looking at your code samples, it seems you want me to instanciate the component twice, which is impossible because the instanciation is made in the component itself. So, the only two workarounds I can see right now would be :
In both cases, I think it's not ideal because it breaks the "Don't repeat Yourself" philosophy, if I want to use the same exact keyboard more than once. Maybe this issue could be marked as "enhancement to respect Angular right way to do" Thanks again. |
Hey @ddahan, I understand what you mean. To accomplish this use case in react for example, I pass the class name to the component though a parameter (prop). Like so: https://simple-keyboard.com/react/qa-use-cases/#give-different-class-keyboard I wonder if using a similar approach would work for your use-case. Something like this:
In any case, for multiple keyboards you do need multiple instances, as the event listeners, rows etc are bound to each keyboard's DOM element. Another approach would be to have a single keyboard serve all the inputs, like so: https://simple-keyboard.com/qa-use-cases/#using-several-inputs Hope this helps, |
You're right it's the way to go for sure. Could you take a look to the updated code here please? https://github.com/ddahan/pockey |
The error makes senses because at EDIT: using EDIT2: specifying the theme in options seems to solve the CSS problem! 👍
|
Awesome! Glad you got it figured out. I will update the Angular demos soon to use |
You are the one to thanks ;) |
Simple-keyboard version
2.14.3
Describe the bug
In Angular 6, when trying to include multiple keyboards in a component (embedding simple keyboard as a component itself), only the first one is displayed/working.
Here is a minimal Github project that shows the issue: https://github.com/ddahan/pockey
Screenshots
Debug
As you can see, the first
app-simple-component
div contains a keyboard html content, but the second div contains nothing.The text was updated successfully, but these errors were encountered: