Skip to content

ui-native: a kept-alive child stops receiving presses after it's placed again #552

Backlog

Description

@Kaeldehta

A child written with h.keepAlive renders again after it's been parked, but its views no longer respond to presses. Elements that never left the tree keep working.

Seen on iOS (Expo Go 58, React Native 0.88.1) with @effect/ui and @effect/ui-native at 22128c6.

Reproduction

view: (h, model) =>
  h.view.style({ flex: 1 }).children(
    h.view.on("press", AppMessage.PressedTab({ tab: "counter" })).children(h.text.children("Counter tab")),
    h.view.on("press", AppMessage.PressedTab({ tab: "other" })).children(h.text.children("Other tab")),
    model.tab === "counter"
      ? h.keepAlive((s) => Counter(s, { key: "counter" }))
      : h.keepAlive((s) => Other(s, { key: "other" }))
  )
  1. Press a button in Counter: it works.
  2. Switch to "Other tab", then back to "Counter tab".
  3. Press the same button: nothing happens. The tab buttons still work.

TestHost and FakeFabric don't reproduce it.

Cause

The kept child comes back under its old tags, so Fabric mounts the same shadow node families again. When those families unmounted, Fabric released their event targets (ShadowNode::setMounted(false) → EventEmitter::setEnabled, which calls eventTarget_.reset()), and mounting them again doesn't restore them. Events from those views never reach the handler registered with registerEventHandler.

Related: #519 handles kept children for animations, but not this.

Activity

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

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