Skip to content

Make the whole iOS button group segment tappable - #126

Open
vmitchell85 wants to merge 1 commit into
NativePHP:mainfrom
vmitchell85:fix/ios-button-group-tap-area
Open

vmitchell85 wants to merge 1 commit into
NativePHP:mainfrom
vmitchell85:fix/ios-button-group-tap-area

Conversation

@vmitchell85

Copy link
Copy Markdown

On iOS, an unselected native:button-group segment only responds to taps on its label text. Tapping the empty space either side of the label does nothing, so short labels like S, M, L have a very small target. The selected segment works across its whole frame.

Each segment is a .plain style Button whose label has Color.clear as its background when unselected. A plain button only hit-tests drawn content, so the clear background doesn't count and only the text receives the tap. The selected segment paints theme.primary, which is why it behaves.

This adds .contentShape(Rectangle()) to the segment label so the whole segment is the tap target. The tab row, chip, and accordion renderers already do the same. Nothing changes visually or on the PHP side, and Android is unaffected because it uses Material's segmented button row.

#123 replaces this renderer with UISegmentedControl, which would also fix the tap area. This is the minimal fix in case that change needs longer to land.

To reproduce, tap just inside the left or right edge of an unselected segment:

<native:button-group class="w-full" :options="['S', 'M', 'L']" :value="$size" @change="pickSize" />
public int $size = 1;

public function pickSize(int $index): void
{
    $this->size = $index;
}

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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