fix(runtime, runtime_wasm): raise the soft keyboard for text focus only (#15428)

Rive-Mono-Commit: b739e5f1f662b6f640d9c9cfa2d5f25e3b5ffa20
diff --git a/include/rive/animation/state_machine_instance.hpp b/include/rive/animation/state_machine_instance.hpp
index 557d736..7add12a 100644
--- a/include/rive/animation/state_machine_instance.hpp
+++ b/include/rive/animation/state_machine_instance.hpp
@@ -548,6 +548,8 @@
     /// TextInput, or a FocusData target with registered key/text-input
     /// listeners. False when nothing is focused.
     bool expectsKeyboardInput = false;
+    /// True if the focused element or an ancestor takes typed text.
+    bool expectsTextInput = false;
   };
   FocusState focusState() const;
 
diff --git a/include/rive/focus_data.hpp b/include/rive/focus_data.hpp
index 563e31c..28883e1 100644
--- a/include/rive/focus_data.hpp
+++ b/include/rive/focus_data.hpp
@@ -100,7 +100,7 @@
   /// Forwards to the parent TextInput's selection (mirroring how
   /// key/text input special-case a TextInput parent).
   bool selectedText(std::string& outText) const override;
-  /// True when the parent is a TextInput (same special case).
+  /// A TextInput parent or text-input listeners.
   bool acceptsTextInput() const override;
   /// Forwards to the parent TextInput (same special case): it asks to blur
   /// on an outside press and owns the hit test for it.
diff --git a/include/rive/input/focusable.hpp b/include/rive/input/focusable.hpp
index d5fe244..8d2c8ab 100644
--- a/include/rive/input/focusable.hpp
+++ b/include/rive/input/focusable.hpp
@@ -203,9 +203,8 @@
   /// clipboard access).
   virtual bool selectedText(std::string& outText) const { return false; }
 
-  /// Whether this focusable consumes typed text (a text input). Lets hosts
-  /// decide to start routing the keyboard to the runtime when one takes
-  /// focus. Default: no.
+  /// Whether this focusable consumes typed text (a text input or text-input
+  /// listeners; keys alone don't). Hosts raise a soft keyboard for it.
   virtual bool acceptsTextInput() const { return false; }
 
   /// Gamepad `ListenerInvocation` from the focus bubble. Default: ignore.
@@ -234,8 +233,7 @@
 
   /// Returns true if this focusable consumes keyboard input — either
   /// intrinsically (e.g. a text-editable input) or by having registered
-  /// key/text listeners. Hosts use this to decide whether to surface a
-  /// soft keyboard / IME when this element holds focus.
+  /// key/text listeners.
   virtual bool acceptsKeyboardInput() const { return false; }
 
   /// Whether a primary press landing outside this focusable takes focus
diff --git a/src/animation/state_machine_instance.cpp b/src/animation/state_machine_instance.cpp
index 93e51fa..8fcab8a 100644
--- a/src/animation/state_machine_instance.cpp
+++ b/src/animation/state_machine_instance.cpp
@@ -5246,6 +5246,8 @@
     return state;
   }
   state.hasFocus = true;
+  // Text bubbles up the focus tree, so an ancestor that takes it counts.
+  state.expectsTextInput = fm->primaryFocusAcceptsText();
   if (Focusable* focusable = focus->focusable())
   {
     state.expectsKeyboardInput = focusable->acceptsKeyboardInput();
diff --git a/src/focus_data.cpp b/src/focus_data.cpp
index c8c0b3f..67c3b35 100644
--- a/src/focus_data.cpp
+++ b/src/focus_data.cpp
@@ -240,7 +240,8 @@
 bool FocusData::acceptsTextInput() const
 {
   Component* target = parent();
-  return target != nullptr && target->is<TextInput>();
+  return !m_textInputListeners.empty() ||
+         (target != nullptr && target->is<TextInput>());
 }
 
 bool FocusData::blursOnOutsidePress() const
diff --git a/tests/unit_tests/runtime/focus_test.cpp b/tests/unit_tests/runtime/focus_test.cpp
index 6db27f8..c386d86 100644
--- a/tests/unit_tests/runtime/focus_test.cpp
+++ b/tests/unit_tests/runtime/focus_test.cpp
@@ -2248,6 +2248,59 @@
   auto state = smi.focusState();
   CHECK(state.hasFocus == true);
   CHECK(state.expectsKeyboardInput == true);
+  CHECK(state.expectsTextInput == false);
+}
+
+namespace
+{
+class TextAcceptingFocusable : public KeyboardAcceptingFocusable
+{
+public:
+  bool acceptsTextInput() const override { return true; }
+};
+} // namespace
+
+TEST_CASE(
+    "StateMachineInstance::focusState reports text expectation when the "
+    "focused focusable takes text",
+    "[FocusState]")
+{
+  NoOpFactory factory;
+  Artboard artboard(&factory);
+  auto instance = instanceWithFocus(artboard);
+  StateMachine machine;
+  StateMachineInstance smi(&machine, instance.get());
+
+  TextAcceptingFocusable tf;
+  auto node = make_rcp<FocusNode>(&tf);
+  smi.focusManager()->addChild(nullptr, node);
+  smi.focusManager()->setFocus(node);
+
+  auto state = smi.focusState();
+  CHECK(state.expectsKeyboardInput == true);
+  CHECK(state.expectsTextInput == true);
+}
+
+TEST_CASE(
+    "StateMachineInstance::focusState reports text expectation from an "
+    "ancestor that takes text",
+    "[FocusState]")
+{
+  NoOpFactory factory;
+  Artboard artboard(&factory);
+  auto instance = instanceWithFocus(artboard);
+  StateMachine machine;
+  StateMachineInstance smi(&machine, instance.get());
+
+  TextAcceptingFocusable parent;
+  KeyboardAcceptingFocusable child;
+  auto parentNode = make_rcp<FocusNode>(&parent);
+  auto childNode = make_rcp<FocusNode>(&child);
+  smi.focusManager()->addChild(nullptr, parentNode);
+  smi.focusManager()->addChild(parentNode, childNode);
+  smi.focusManager()->setFocus(childNode);
+
+  CHECK(smi.focusState().expectsTextInput == true);
 }
 
 TEST_CASE(
@@ -2519,6 +2572,21 @@
 }
 
 TEST_CASE(
+    "a focus data takes text only with a text-input listener",
+    "[FocusData]")
+{
+  FocusData focusData;
+  RecordingKeyboardListener keys(/*claims=*/true);
+  focusData.addKeyboardListener(&keys);
+  CHECK(focusData.acceptsKeyboardInput());
+  CHECK_FALSE(focusData.acceptsTextInput());
+
+  RecordingKeyboardListener text(/*claims=*/false);
+  focusData.addTextInputListener(&text);
+  CHECK(focusData.acceptsTextInput());
+}
+
+TEST_CASE(
     "a focus data with no claiming listener reports unhandled",
     "[FocusData]")
 {