Skip to content

Nested Foreground Element in Laravel Prompts select Title Renders Incorrectly #189

@imakeinternet

Description

@imakeinternet

Laravel Prompts Version

0.3.5

Laravel Version

12.7.2

PHP Version

8.2.27

Operating System & Version

macOS 14.7.4

Terminal Application

zsh

Description

When using Laravel Prompts' select() method with a nested foreground (<fg> tag) element in the title, the prompt title renders incorrectly.

Steps to Reproduce:

Using the following code produces the issue:

$action = select("<fg=green>Your action, <fg=yellow>{$this->user->name}</>?</>", $actionOptions);

This renders incorrectly:

Image

However, when using the following code (without nested foreground elements), it renders correctly:

$action = select("<fg=green>Your action, {$this->user->name}?</>", $actionOptions);

This renders correctly:

Image

Expected Behavior:
Nested foreground elements should render correctly within the select title.

Actual Behavior:
Nested foreground elements cause incorrect rendering.

Additional Information:

  • Laravel Prompts is being used within Laravel v12.7.2
  • Issue reproducible consistently with nested tags

Suggested Fix:
Handle nested foreground formatting correctly in the prompt renderer or clarify limitations in the documentation if nested formatting isn't supported.

Steps To Reproduce

  1. Create a new Laravel project or use an existing Laravel 12.7.2 installation.
  2. Within a Laravel Command or Controller, include the following code snippet:
$actionOptions = ['Attack', 'Run', 'Mighty Blow (Deal 2x damage with a powerful strike)'];

$action = select("<fg=green>Your action, <fg=yellow>UserName</>?</>", $actionOptions);
  1. Run the Laravel command or controller action that executes this code.
  2. Observe the rendering of the prompt title in the terminal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions