Skip to content

fix: let a chip's @press handler actually fire - #80

Open
CodyPChristian wants to merge 1 commit into
NativePHP:mainfrom
CodyPChristian:fix/chip-press-handler
Open

fix: let a chip's @press handler actually fire#80
CodyPChristian wants to merge 1 commit into
NativePHP:mainfrom
CodyPChristian:fix/chip-press-handler

Conversation

@CodyPChristian

Copy link
Copy Markdown
Contributor

A <chip> read on_change but never on_press, so a press handler was silently ignored — the chip rendered, animated its selection, and told the server nothing.

Why it can't just also send a change event

When a press handler exists, selection is server-driven: the handler decides what is selected and hands the state back. Toggling locally as well makes the chip fight the value it is given — a filter chip flickers off on its own tap, then snaps back when the server response lands.

So the two paths are exclusive:

  • on_press set → send the press event only, and leave isSelected alone. The server owns it.
  • otherwise → the existing local toggle plus on_change, unchanged.

Applied to both NativeUIChipRenderer.swift and ChipRenderer.kt so the platforms agree.

Existing @change chips are unaffected — that branch is untouched.

Both chip renderers read only `on_change`. A chip written as

    <chip label="…" :selected="…" @press="filterRole('admin')" />

registers the callback PHP-side — Element::onPress exists and
NativeElementCollector binds `_press` for every element — and then nothing
invokes it, because neither renderer looks for `on_press`. The chip toggles its
own local state and reports a boolean instead.

Nothing errors. The chip animates on tap, so it reads as working; the filter
simply never changes. In the QikCMS console this silently disabled the filter
row on THIRTEEN screens, People and Tickets among them.

A chip with a press handler is server-driven: the handler decides what becomes
selected, so it must not toggle locally, or a filter chip fights the state it
is handed back and flickers off on its own tap. Without a press handler the
existing self-toggling `@change` behaviour is untouched.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RWJoCjdX5Cy1V5VhaRKuLS
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