Giter VIP home page Giter VIP logo

Comments (6)

emilykl avatar emilykl commented on May 27, 2024 1

@Coding-with-Adam @nadijagraca I am seeing the issue on Mac in Safari and Chrome. No issue in Firefox because the box is wider overall in Firefox. I wonder what is causing the width difference between browsers.

With step=None on the dcc.Input:
Screen Shot 2024-03-21 at 11 57 15 AM
Screen Shot 2024-03-21 at 11 57 29 AM

With step=0.5:
Screen Shot 2024-03-21 at 4 47 21 PM

Odd that the width of the box is affected by the value of step!

Worth noting, though, that setting step=None isn't really valid according to the docs — the default value for step is "any". Setting step="any", or not passing a value for step at all, gives a wider box, even in Safari/Chrome:
Screen Shot 2024-03-21 at 5 00 09 PM

If I were to guess I would say dcc.Input is doing some fancy logic to try to guess the minimum length needed for the input box, but is not handling the null value correctly.

from dash.

emilykl avatar emilykl commented on May 27, 2024 1

After another look I see that dcc.Input is a pretty light wrapper around the HTML <input> component, and the logic around choosing the box width is implemented by the browser, based on the min, max and step values. Which explains why the behavior is different across browsers.

So the answer here I think is

  1. set step="any" (or don't pass a value for step, meaning the default of "any" will be used) to nudge the browser to use the 'default' input field width which is around 20 characters, OR
  2. use CSS to set a different, custom, width if needed

from dash.

Coding-with-Adam avatar Coding-with-Adam commented on May 27, 2024

HI @nadijagraca
Thank you for reporting this. Can you please share a minimal reproducible example code so we can replicated this bug locally?

from dash.

nadijagraca avatar nadijagraca commented on May 27, 2024

Hi Adam,
Apologies for not including it.

Below you can find example code. If you replace step=None with step=0.5 the number in the input field is displayed correctly.

from dash import Dash, Input, Output, callback, dcc, html

app = Dash(__name__)

app.layout = html.Div(
    [
        dcc.Input(id="input-slider", type="number", min=1957, max=2007, step=None, value=1990),
        dcc.Slider(
             id="slider", min=1957, max=2007, marks=None, value=1990, dots=False, step=None, updatemode="drag"
        ),
    ]
)


@callback(Output("input-slider", "value"), Input("slider", "value"))
def update_output(value):
    return value


if __name__ == '__main__':
    app.run(debug=True)

Screenshot 2024-03-13 at 11 56 37

To replicate the bug you will need to use slider handle, and once the slider handle is dragged to the number with decimal place, you will notice that the decimal place is being cut-off from the input field.

from dash.

Coding-with-Adam avatar Coding-with-Adam commented on May 27, 2024

hi @nadijagraca
Thanks for sharing the code. For some reason, I'm not able to reproduce the error. I ran your code as step=None and step=0.5, and in bot cases the complete number/float is visible.

I'm using Dash 2.16.1 on a Windows 11. And it worked fine on Firefox, Edge, and Brave.
Can you try Dash 2.16.1? What OS are you using?

slider1

from dash.

Coding-with-Adam avatar Coding-with-Adam commented on May 27, 2024

Thank you for the solution, @emilykl

from dash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.