Skip to content

number_input cannot handle spaces in numbers in firefox #12465

@AlexAuragan

Description

@AlexAuragan

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

The issue is quite simple, spaces in numbers break the number_input widget.

I don't think the streamlit widget allows me to preprocess the string, like removing spaces or comma separating thousands.

I am not sure if this is a bug or a feature request and I am sorry if this is not the right tag.

While a comma can mean different things in French and in English, I believe spaces universally only are there to separate 1000s, and I would guess it would be both fairly easy and intuitive to implement.

Additionally, the "buggy" input still returns None, which is the default value I have set in my example, this means I cannot filter a faulty input and no input at all. One could argue that I shouldn't use None as my default value, but it seems to me this would be standard for an optional input.

Reproducible Code Example

Open in Streamlit Cloud

import streamlit as st

st.number_input(
    "Test number input",
    value=None,
    help="The input cannot handle number with spaces in it.",
    key="number",
)
st.write(st.session_state["number"])

Steps To Reproduce

input any number with a space in it like "100 000" the output would be None.

Expected Behavior

st.number_input should either accept numbers with spaces in it, allow the user to pre-process the string or raise / output something more explicit in case of a buggy input

Current Behavior

No response

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.49.1
  • Python version: 3.11

Additional Information

I'm currently building an interface for non-tech-savvy coworkers, and they are meant to copy paste numbers into my interface.
This means I would either teach all of them that there is this quirk with streamlit they have to adapt to or turn the number_input into a text input, which is such a shame.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:st.number_inputRelated to the `st.number_input` widgettype:enhancementRequests for feature enhancements or new features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions