Skip to content

Fix typing cursor to follow text inline#9

Merged
kushal238 merged 1 commit into
mainfrom
fix/inline-typing-cursor
Mar 4, 2026
Merged

Fix typing cursor to follow text inline#9
kushal238 merged 1 commit into
mainfrom
fix/inline-typing-cursor

Conversation

@kushal238

@kushal238 kushal238 commented Mar 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix blinking cursor in Smart Medication Search and AI-Aided Diagnosis demos to render inline after the last typed character instead of being pinned to the far right of the input field

What changed?

Both demos used absolute right-3 positioning for the typing cursor, which looked unnatural since the typed text is left-aligned. Replaced the readonly <input>/<textarea> + absolute-positioned cursor with styled <div>s that render text and an inline <motion.span> cursor side by side, matching the approach already used in the Smart Dictation demo.

  • src/components/FeatureShowcase.tsx: Converted medication search input and diagnosis complaints textarea from absolute cursor overlay to inline cursor rendering

Test plan

  • Watch Smart Medication Search typing animation -- cursor follows "croc" and "reju" text
  • Watch AI-Aided Diagnosis typing animation -- cursor follows complaint text as it wraps
  • Cursor blinks correctly in both demos
  • Cursor disappears on medication selection (existing behavior)
  • Placeholder text shows when input is empty
  • Mobile responsive sizing preserved

Replace absolute-positioned cursors in Smart Medication Search and
AI-Aided Diagnosis demos with inline spans that render immediately
after the last typed character, matching natural cursor behavior.
@vercel

vercel Bot commented Mar 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ariamed Ready Ready Preview, Comment Mar 4, 2026 9:24pm

@kushal238
kushal238 merged commit 8d9217e into main Mar 4, 2026
2 of 3 checks passed
@kushal238
kushal238 deleted the fix/inline-typing-cursor branch March 4, 2026 21:24
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the user experience in the Smart Medication Search and AI-Aided Diagnosis demos by rectifying an unnatural cursor behavior. By transitioning from an absolute-positioned cursor to an inline rendering method, the typing animation now appears more intuitive and visually consistent with user expectations, making the interactive elements feel more polished and responsive.

Highlights

  • Cursor Positioning Fix: The blinking cursor in the Smart Medication Search and AI-Aided Diagnosis demos now renders inline with the typed text, rather than being fixed to the right of the input field.
  • Implementation Change: The previous absolute positioning of the cursor within <input>/<textarea> elements was replaced with styled <div>s that render text and an inline <motion.span> for the cursor, mirroring the approach used in the Smart Dictation demo.
Changelog
  • src/components/FeatureShowcase.tsx
    • Refactored the medication search input and AI-Aided Diagnosis complaints textarea to use inline cursor rendering instead of an absolute overlay.
Activity
  • Verified that the cursor correctly follows the text during typing animations in the Smart Medication Search demo.
  • Confirmed that the cursor follows the complaint text, including wrapping, in the AI-Aided Diagnosis demo.
  • Ensured the cursor blinks as expected in both updated demos.
  • Validated that the cursor disappears upon medication selection, maintaining existing behavior.
  • Checked that placeholder text is displayed when input fields are empty.
  • Confirmed that mobile responsive sizing remains intact after the changes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully fixes the typing cursor animation to be inline with the text, which is a great visual improvement. The implementation is clean and consistent with other parts of the showcase. My main feedback is regarding accessibility. By replacing semantic <input> and <textarea> elements with <div>s, we've lost some accessibility features. I've added a couple of suggestions to add ARIA attributes to the new div elements to restore their semantic meaning for screen reader users.

Comment on lines +312 to 327
<div className="w-full px-3 md:px-4 py-2 md:py-3 border border-border/70 rounded-lg bg-background transition-colors text-sm md:text-base font-medium mb-2 min-h-[2.5rem] md:min-h-[2.75rem] flex items-center">
{medicationInput ? (
<span>
{medicationInput}
{medicationInput.length < 10 && !selectedMedication && (
<motion.span
animate={{ opacity: [1, 0] }}
transition={{ repeat: Infinity, duration: 0.8 }}
className="inline-block w-0.5 h-4 md:h-5 bg-foreground/60 align-middle ml-px"
/>
)}
</span>
) : (
<span className="text-muted-foreground">Start typing medication name...</span>
)}
</div>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While this change correctly implements the inline cursor, replacing the <input> element with a <div> harms accessibility. The new element is not focusable and lacks semantic meaning for screen readers. We can restore accessibility by adding role, aria-readonly, aria-label, and tabIndex attributes to the div.

Suggested change
<div className="w-full px-3 md:px-4 py-2 md:py-3 border border-border/70 rounded-lg bg-background transition-colors text-sm md:text-base font-medium mb-2 min-h-[2.5rem] md:min-h-[2.75rem] flex items-center">
{medicationInput ? (
<span>
{medicationInput}
{medicationInput.length < 10 && !selectedMedication && (
<motion.span
animate={{ opacity: [1, 0] }}
transition={{ repeat: Infinity, duration: 0.8 }}
className="inline-block w-0.5 h-4 md:h-5 bg-foreground/60 align-middle ml-px"
/>
)}
</span>
) : (
<span className="text-muted-foreground">Start typing medication name...</span>
)}
</div>
<div role="textbox" aria-readonly="true" aria-label="Medication Name (type to search)" tabIndex={0} className="w-full px-3 md:px-4 py-2 md:py-3 border border-border/70 rounded-lg bg-background transition-colors text-sm md:text-base font-medium mb-2 min-h-[2.5rem] md:min-h-[2.75rem] flex items-center">
{medicationInput ? (
<span>
{medicationInput}
{medicationInput.length < 10 && !selectedMedication && (
<motion.span
animate={{ opacity: [1, 0] }}
transition={{ repeat: Infinity, duration: 0.8 }}
className="inline-block w-0.5 h-4 md:h-5 bg-foreground/60 align-middle ml-px"
/>
)}
</span>
) : (
<span className="text-muted-foreground">Start typing medication name...</span>
)}
</div>

Comment on lines +740 to 755
<div className="w-full px-3 md:px-4 py-2 md:py-3 border border-border/70 rounded-lg bg-background transition-colors text-xs md:text-sm min-h-[70px] md:min-h-[80px]">
{complaints ? (
<span>
{complaints}
{complaints.length < fullComplaintsText.length && (
<motion.span
animate={{ opacity: [1, 0] }}
transition={{ repeat: Infinity, duration: 0.8 }}
className="inline-block w-0.5 h-3 md:h-4 bg-foreground/60 align-middle ml-px"
/>
)}
</span>
) : (
<span className="text-muted-foreground">Enter patient complaints...</span>
)}
</div>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to the medication search input, replacing the <textarea> with a <div> harms accessibility. Let's add ARIA attributes to make this element accessible to screen reader users. Since this is a multi-line field, we should also add aria-multiline="true".

Suggested change
<div className="w-full px-3 md:px-4 py-2 md:py-3 border border-border/70 rounded-lg bg-background transition-colors text-xs md:text-sm min-h-[70px] md:min-h-[80px]">
{complaints ? (
<span>
{complaints}
{complaints.length < fullComplaintsText.length && (
<motion.span
animate={{ opacity: [1, 0] }}
transition={{ repeat: Infinity, duration: 0.8 }}
className="inline-block w-0.5 h-3 md:h-4 bg-foreground/60 align-middle ml-px"
/>
)}
</span>
) : (
<span className="text-muted-foreground">Enter patient complaints...</span>
)}
</div>
<div role="textbox" aria-readonly="true" aria-multiline="true" aria-label="Chief Complaints" tabIndex={0} className="w-full px-3 md:px-4 py-2 md:py-3 border border-border/70 rounded-lg bg-background transition-colors text-xs md:text-sm min-h-[70px] md:min-h-[80px]">
{complaints ? (
<span>
{complaints}
{complaints.length < fullComplaintsText.length && (
<motion.span
animate={{ opacity: [1, 0] }}
transition={{ repeat: Infinity, duration: 0.8 }}
className="inline-block w-0.5 h-3 md:h-4 bg-foreground/60 align-middle ml-px"
/>
)}
</span>
) : (
<span className="text-muted-foreground">Enter patient complaints...</span>
)}
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant