Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(polls/web) fixed issue with duplicating value to next input on keypress

Calin Chitu03286eb07e64
diff --git a/react/features/polls/components/web/PollCreate.js b/react/features/polls/components/web/PollCreate.js
index 49c50a89da..16e1612fa0 100644
--- a/react/features/polls/components/web/PollCreate.js
+++ b/react/features/polls/components/web/PollCreate.js
@@ -60,6 +60,18 @@ const PollCreate = (props: AbstractProps) => {
}, [ lastFocus ]);
const checkModifiers = useCallback(ev => {
+ // Composition events used to add accents to characters
+ // despite their absence from standard US keyboards,
+ // to build up logograms of many Asian languages
+ // from their base components or categories and so on.
+ if (ev.isComposing || ev.keyCode === 229) {
+ // keyCode 229 means that user pressed some button,
+ // but input method is still processing that.
+ // This is a standard behavior for some input methods
+ // like entering japanese or сhinese hieroglyphs.
+ return true;
+ }
+
// Because this isn't done automatically on MacOS
if (ev.key === 'Enter' && ev.metaKey) {
ev.preventDefault();
@@ -90,7 +102,11 @@ const PollCreate = (props: AbstractProps) => {
}
if (ev.key === 'Enter') {
- addAnswer(i + 1);
+ // We add a new option input
+ // only if we are on the last option input
+ if (i === answers.length - 1) {
+ addAnswer(i + 1);
+ }
requestFocus(i + 1);
ev.preventDefault();
} else if (ev.key === 'Backspace' && ev.target.value === '' && answers.length > 1) {