Skip to content

Conversation

@lethargicpanda
Copy link
Collaborator

Fix the expanded TextField

Before After
Before After
@lethargicpanda
Copy link
Collaborator Author

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lethargicpanda, 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 addresses a layout issue in several AI sample applications where interactive elements positioned next to multi-line text input fields failed to resize appropriately when the text field expanded. The changes ensure that these companion buttons now dynamically adjust their height to match the text input, providing a more consistent and responsive user interface across the affected screens.

Highlights

  • TextField Expansion Fix: The primary issue where buttons adjacent to a TextField did not correctly expand their height when the TextField content grew has been resolved, ensuring visual consistency.
  • UI Component Refinement: The core TextInput composable in the ui-component module has been updated to properly manage its children's height using IntrinsicSize.Min and fillMaxHeight() modifiers.
  • Consistent Button Sizing Across Samples: Interactive buttons (e.g., send, image picker, mic, generate) in various AI sample applications now dynamically adjust their height to match the expanded TextField, improving the overall user experience.
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.

Copy link
Contributor

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

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 aims to fix an issue where the TextField does not expand vertically for multiline input. The approach of using Modifier.height(IntrinsicSize.Min) on the container Row and Modifier.fillMaxHeight() on the adjacent buttons is correct.

However, there are a few issues with the current implementation:

  1. Critical Flaw: The custom GenerateButton and SecondaryButton components have hardcoded height() modifiers within their implementation in ui-component/src/main/java/com/android/ai/uicomponent/Buttons.kt. This overrides the fillMaxHeight() modifier applied in this PR, preventing the buttons from resizing vertically with the TextField. This makes the intended fix ineffective. The hardcoded heights must be removed from Buttons.kt for this PR to work as expected.

  2. Inconsistent Updates: In some sample screens, not all buttons within the TextInput have been updated. Specifically:

    • In samples/gemini-live-todo/src/main/java/com/android/ai/samples/geminilivetodo/ui/TodoScreen.kt, the SecondaryButton still has a fixed height.
    • In samples/gemini-multimodal/src/main/java/com/android/ai/samples/geminimultimodal/ui/GeminiMultimodalScreen.kt, the SecondaryButton also retains a fixed height.
  3. Fixed Height on TextInput: In samples/magic-selfie/src/main/java/com/android/ai/samples/magicselfie/ui/MagicSelfieScreen.kt, the TextInput component itself is constrained to a fixed height(80.dp). This will prevent it from expanding, defeating the purpose of the intrinsic sizing. This fixed height should be removed.

I've added a specific comment highlighting the critical flaw. The other points should also be addressed to fully resolve the issue.

}
GenerateButton(
modifier = Modifier
.height(56.dp)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is this one hard-coded and not fillMaxHeight?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's intentional to keep the maintain the height of the button. After checking the design it should actually be 96dp, I am increasing it.

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

Labels

None yet

2 participants