Skip to content

Commit 500984b

Browse files
committed
feat: improve mobile keyboard interaction for SplitFlapDisplay
1 parent 2c4d0f1 commit 500984b

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

frontend/src/components/SplitFlapDisplay.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,16 @@ const SplitFlapDisplay: React.FC<SplitFlapDisplayProps> = ({
3737
if (isInteractive && isConnected) {
3838
// Focus the hidden input to show keyboard on mobile
3939
if (hiddenInputRef.current) {
40-
hiddenInputRef.current.focus({
41-
preventScroll: true // Prevent page from scrolling when focusing
42-
});
40+
// Force blur and then focus to ensure keyboard appears on iOS
41+
hiddenInputRef.current.blur();
42+
// Small timeout to ensure the blur completes
43+
setTimeout(() => {
44+
if (hiddenInputRef.current) {
45+
hiddenInputRef.current.focus();
46+
// On iOS, we may need to trigger a click on the input
47+
hiddenInputRef.current.click();
48+
}
49+
}, 10);
4350
}
4451

4552
// Call the original onClick handler if provided
@@ -112,13 +119,13 @@ const SplitFlapDisplay: React.FC<SplitFlapDisplayProps> = ({
112119
autoCapitalize="characters"
113120
style={{
114121
position: 'absolute',
115-
opacity: 0,
122+
opacity: 0.01, // Very slight opacity instead of 0
116123
height: '100%', // Make it cover the entire display area
117124
width: '100%', // Make it cover the entire display area
118125
left: 0,
119126
top: 0,
120-
pointerEvents: 'none', // This allows clicks to pass through to the display
121-
zIndex: -1
127+
zIndex: 1, // Place above the display
128+
background: 'transparent'
122129
}}
123130
onInput={handleHiddenInput}
124131
onKeyDown={(e) => {
@@ -134,6 +141,11 @@ const SplitFlapDisplay: React.FC<SplitFlapDisplayProps> = ({
134141
onKeyDown(simulatedEvent);
135142
}
136143
}}
144+
// Add click handler directly to the input
145+
onClick={(e) => {
146+
// Stop propagation to prevent double-handling with the div's click
147+
e.stopPropagation();
148+
}}
137149
/>
138150
)}
139151
</div>

0 commit comments

Comments
 (0)