mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 17:55:01 +00:00
SpeechToText js : use only reactProps
This commit is contained in:
parent
e2dc7f6332
commit
4379a74f9d
1 changed files with 3 additions and 24 deletions
|
@ -52,12 +52,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Try to access React internals
|
|
||||||
const reactProps = Object.keys(chatInput).find(key => key.startsWith('__reactProps$'));
|
const reactProps = Object.keys(chatInput).find(key => key.startsWith('__reactProps$'));
|
||||||
|
|
||||||
if (reactProps && chatInput[reactProps] && chatInput[reactProps].onChange) {
|
if (reactProps && chatInput[reactProps] && chatInput[reactProps].onChange) {
|
||||||
// If we can access React props, use the onChange handler directly
|
|
||||||
|
|
||||||
// Append to the existing value
|
// Append to the existing value
|
||||||
chatInput.value = chatInput.value + ' ' + text;
|
chatInput.value = chatInput.value + ' ' + text;
|
||||||
|
|
||||||
|
@ -78,26 +75,8 @@
|
||||||
// Call React's onChange handler
|
// Call React's onChange handler
|
||||||
chatInput[reactProps].onChange(syntheticEvent);
|
chatInput[reactProps].onChange(syntheticEvent);
|
||||||
} else {
|
} else {
|
||||||
// Fallback to standard DOM approach with multiple event types
|
console.error("Could not find React props on chat input");
|
||||||
|
return false;
|
||||||
// Focus first
|
|
||||||
chatInput.focus();
|
|
||||||
|
|
||||||
// Append to the existing value
|
|
||||||
chatInput.value = chatInput.value + text;
|
|
||||||
|
|
||||||
// Dispatch multiple event types to ensure detection
|
|
||||||
['input', 'change', 'blur', 'keydown', 'keyup'].forEach(eventType => {
|
|
||||||
const event = new Event(eventType, { bubbles: true, cancelable: true });
|
|
||||||
chatInput.dispatchEvent(event);
|
|
||||||
});
|
|
||||||
|
|
||||||
// For Streamlit specifically, try to trigger any MutationObservers or polling
|
|
||||||
// that might be watching for changes
|
|
||||||
setTimeout(() => {
|
|
||||||
chatInput.dispatchEvent(new Event('change', { bubbles: true }));
|
|
||||||
chatInput.dispatchEvent(new Event('blur', { bubbles: true }));
|
|
||||||
}, 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue