Skip to content

Commit c16fa58

Browse files
committed
Cursor issue on iOS fixed
1 parent bd94f42 commit c16fa58

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

src/components/GitSequencer.css

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,12 @@
207207
background: var(--success);
208208
pointer-events: none;
209209
z-index: 1;
210-
opacity: 0;
211-
transition: left 0.05s ease-out;
212-
}
213-
214-
/* Show and blink cursor when input is focused */
215-
.input-wrapper:focus-within .terminal-cursor {
216210
opacity: 0.85;
217211
animation: blink-cursor 1s step-end infinite;
212+
transition: left 0.05s ease-out;
218213
}
219214

215+
220216
@keyframes blink-cursor {
221217
0%, 100% { opacity: 0.85; }
222218
50% { opacity: 0; }

src/components/GitSequencer.jsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const GitSequencer = () => {
4040
const inputRef = useRef(null);
4141
const measureRef = useRef(null);
4242
const [cursorPos, setCursorPos] = useState(0);
43+
const [showCursor, setShowCursor] = useState(true);
4344

4445
// Custom hooks for audio
4546
const audioEngine = useAudioEngine(username, volume);
@@ -603,22 +604,31 @@ const GitSequencer = () => {
603604
<span className="cmd">git-music fetch</span>
604605
<div className="input-wrapper">
605606
<span ref={measureRef} className="input-measure" aria-hidden="true" />
606-
<span
607-
className="terminal-cursor"
608-
style={{ left: `calc(0.5rem + ${getCursorOffset()}px)` }}
609-
/>
607+
{showCursor && (
608+
<span
609+
className="terminal-cursor"
610+
style={{ left: `calc(0.5rem + ${getCursorOffset()}px)` }}
611+
/>
612+
)}
610613
<input
611614
ref={inputRef}
612615
type="text"
613616
value={username}
614617
onChange={(e) => {
615618
setUsername(e.target.value);
619+
setShowCursor(true);
616620
setTimeout(updateCursorPos, 0);
617621
}}
618622
onKeyUp={updateCursorPos}
619623
onMouseUp={updateCursorPos}
620624
onSelect={updateCursorPos}
625+
onFocus={() => setShowCursor(true)}
621626
onBlur={() => {
627+
// Hide cursor only if there's content
628+
if (username) {
629+
setShowCursor(false);
630+
}
631+
// Trigger load on blur
622632
if (username && username.length >= 2 && !isLoading) {
623633
if (isPlaying) stop();
624634
loadData(username);

src/hooks/useSequencer.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,13 @@ export function useSequencer(audioEngine) {
158158
// Stop playback
159159
const stop = useCallback(() => {
160160
Tone.Transport.stop();
161-
if (sequenceRef.current) sequenceRef.current.stop();
161+
Tone.Transport.cancel(); // Clear all scheduled events
162+
Tone.Transport.position = 0; // Reset position
163+
if (sequenceRef.current) {
164+
sequenceRef.current.stop();
165+
sequenceRef.current.dispose();
166+
sequenceRef.current = null;
167+
}
162168
setIsPlaying(false);
163169
setActiveCol(-1);
164170
setActiveNotes([]);

0 commit comments

Comments
 (0)