posit-dev / posit-dev/py-shiny

Add option to send text input only after pressing return key

Open
#495 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.8k
Forks
135
Avg merge
2d 18h
Merged PRs (30d)
21

Description

Ask: Please consider adding an option to input_text_input and input_text_area_input to only send new input information after the user presses the return key. Below links to the bindings I have used with R-shiny.

Why: My apps ask users to input filters, arguments, and commands. This will throw errors if the user input is not complete. Adding an input_action_button works only for the first text entry. Once the action button has been pushed, any changes to the user text input are immediately sent for processing.

I have tested the js scripts linked below with the input_text_area function below and it works. All that should be needed is to (1) source the js and (2) append "returnTextArea" to the classes list.

Thank you for your consideration.

https://github.com/radiant-rstats/radiant.data/blob/master/inst/app/www/js/returnTextAreaBinding.js

https://github.com/radiant-rstats/radiant.data/blob/master/inst/app/www/js/returnTextInputBinding.js

def input_return_text_area(
    id,
    label,
    value="",
    rows=1,
    placeholder="",
    resize="vertical",
    autocomplete=False,
    spellcheck=False,
):
    classes = ["form-control", "returnTextArea"]
    area = tags.textarea(
        value,
        id=id,
        class_=" ".join(classes),
        style=css(width="100%", height=None, resize=resize),
        placeholder=placeholder,
        rows=rows,
        cols=None,
        autocomplete=autocomplete,
        spellcheck=spellcheck,
    )

    def shiny_input_label(id, label=None):
        cls = "control-label" + ("" if label else " shiny-label-null")
        return tags.label(label, class_=cls, id=id + "-label", for_=id)

    return div(
        shiny_input_label(id, label),
        area,
        None,
        class_="form-group shiny-input-container",
        style=css(width="100%"),
    )

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the input_text_input and input_text_area_input entry points, then read the referenced returnTextInputBinding.js and returnTextAreaBinding.js bindings. Determine how the bindings integrate with py-shiny and identify the relevant tests; done means text changes are not sent until Return is pressed for both input types.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, python
Domain
frontend, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.