maui icon indicating copy to clipboard operation
maui copied to clipboard

[MAUI] - iOS SearchBar ignores WidthRequest and HeightRequest property values

Open prakashKannanSf3972 opened this issue 11 months ago • 1 comments

Description

The SearchBar control fails to respect explicitly defined Height and Width property values.

Expected Behavior:

  • SearchBar should render with the dimensions specified through Height and Width properties
  • The control should maintain these defined dimensions regardless of available container space

Android

Image

Actual Behavior:

  • SearchBar expands to fill the entire available space in its container
  • Explicitly set Height and Width properties are ignored - The control always defaults to the maximum available dimensions

iOS

Image

Mac

Image

Steps to Reproduce

Add the following XAML code

<StackLayout>
       <VerticalStackLayout
           Padding="30,0"
           Spacing="25">
           <SearchBar 
                      Placeholder="Search..."
                      WidthRequest="200"/>
       </VerticalStackLayout>

       <HorizontalStackLayout>
           <SearchBar 
                      Placeholder="Search..."
                      HeightRequest="200"/>
       </HorizontalStackLayout>
</StackLayout>

Observe that:

  • The first SearchBar ignores the WidthRequest="200" and spans the full width
  • The second SearchBar ignores the HeightRequest="200" and maintains default height

Link to public reproduction project repository

No response

Version with bug

9.0.30 SR3

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

iOS, macOS

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output


prakashKannanSf3972 avatar Jan 29 '25 06:01 prakashKannanSf3972

I'm getting this too. Is there are workaround for now @prakashKannanSf3972 ?

Actually if I do this, it works:

      <HorizontalStackLayout WidthRequest="170">
          <SearchBar 
            Text=""
          />
      </HorizontalStackLayout>

6pac avatar Feb 14 '25 07:02 6pac