Skip to content

Conversation

cpsievert
Copy link
Collaborator

@cpsievert cpsievert commented Oct 15, 2025

Related rstudio/bslib#1204

Adds input_submit_textarea(), a new input control that's akin to input_textarea(), but delays the sending of an input value until a corresponding button is pressed.

Here is a hello world example:

import time

from shiny.express import input, render, ui

ui.input_submit_textarea("text", placeholder="Enter some input...")


@render.text
def value():
    if "text" in input:
        # Simulate processing time
        time.sleep(2)
        return f"You entered: {input.text()}"
    else:
        return "Submit some input to see it here."

@cpsievert cpsievert requested a review from Copilot October 15, 2025 17:40
Copilot

This comment was marked as outdated.

@cpsievert cpsievert requested a review from Copilot October 15, 2025 18:23
Copilot

This comment was marked as resolved.

@cpsievert cpsievert requested a review from gadenbuie October 15, 2025 18:24
"""
self.loc_button.click(timeout=timeout)

def expect_rows(self, value: AttrValue, *, timeout: Timeout = None) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since expect_rows() is duplicated in both InputSubmitTextarea and InputTextArea, we could make it a mixin similar to this

class _ExpectRowsAttrM:
    """A mixin class for the rows attribute."""

    def expect_rows(
        self: UiBaseP,
        value: AttrValue,
        *,
        timeout: Timeout = None,
    ) -> None:
        """
        Expect the `rows` attribute to have a specific value.

        Parameters
        ----------
        value
            The expected value of the `rows` attribute.
        timeout
            The maximum time to wait for the expectation to be fulfilled. Defaults to `None`.
        """
        _expect_attribute_to_have_value(self.loc, "rows", value=value, timeout=timeout)

so then the classes will look like

  class InputTextArea(
      _SetTextM,
      WidthContainerStyleM,
      _ExpectTextInputValueM,
      _ExpectPlaceholderAttrM,
      _ExpectAutocompleteAttrM,
      _ExpectSpellcheckAttrM,
      _ExpectRowsAttrM,
      UiWithLabel,
  ):
      """Controller for :func:`shiny.ui.input_text_area`."""
      .
      .
      .
  class InputSubmitTextarea(
      _SetTextM,
      WidthContainerStyleM,
      _ExpectTextInputValueM,
      _ExpectPlaceholderAttrM,
      _ExpectRowsAttrM,
      UiWithLabel,
  ):
      """Controller for :func:`shiny.ui.input_submit_textarea`."""

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.

2 participants