plotly / plotly/dash

[BUG] `dcc.RangeSlider` ignores `allowCross=False` and lets handles cross

Aperta
#3,935 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug P2 size: 1
Lingua principale
Python
Stelle
24.4k
Fork
2.3k
Merge medio
2g 7h
PR unite (30g)
13

Descrizione

Context

dash 4.4.1 (editable source checkout)
  • Reproduced at commit: 3d3a9f70f452fba4dc385db94590009ce44031fc
  • OS: Ubuntu 24.04.4 LTS
  • Browser: Google Chrome 151.0.7922.71

The bug

dcc.RangeSlider does not enforce allowCross=False. When the lower thumb is
dragged past the upper thumb, the dragged thumb crosses it and becomes the new
upper thumb.

For example, a slider starting at [5, 15] ends at [15, 18] after its lower
thumb is dragged toward 18. The returned array is still sorted, but the thumb
identity and resulting interval prove that crossing occurred despite being
explicitly disabled. Application callbacks therefore cannot rely on the
allowCross=False constraint.

Minimal reproducible example
from dash import Dash, Input, Output, dcc, html


app = Dash(__name__)
app.layout = html.Div(
    style={"margin": "80px auto", "width": "500px"},
    children=[
        dcc.RangeSlider(
            id="range-slider",
            min=0,
            max=20,
            step=1,
            value=[5, 15],
            allowCross=False,
            updatemode="drag",
            tooltip={"always_visible": True},
        ),
        html.Pre(id="range-output", style={"marginTop": "40px"}),
    ],
)


@app.callback(
    Output("range-output", "children"),
    Input("range-slider", "value"),
    Input("range-slider", "drag_value"),
)
def show_values(value, drag_value):
    return f"value={value}\ndrag_value={drag_value}"


if __name__ == "__main__":
    app.run()
Steps to reproduce
  1. Run the example and open http://127.0.0.1:8050.
  2. Drag the lower handle from 5 past the upper handle at 15, toward 18.
  3. Observe that the dragged thumb passes the other thumb and the callback
    reports value=[15, 18] and drag_value=[15, 18].

Expected behavior

With allowCross=False, a handle should stop when it reaches its neighboring
handle. In the example above, dragging the lower handle toward 18 should
clamp both handles at 15, producing:

value=[15, 15]
drag_value=[15, 15]

The same no-cross constraint should apply to pointer, keyboard, Home/End, and
direct-input interactions, with both updatemode="drag" and
updatemode="mouseup".

Screenshots

The bug at commit 3d3a9f70f;

Image

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Parti dall’implementazione di dcc.RangeSlider e riproduci l’esempio minimo con allowCross=False. Traccia le interazioni con il puntatore, la tastiera, Home/End e l’input diretto con entrambi gli updatemodes, quindi individua o aggiungi la copertura per ogni percorso. Il lavoro è completato quando le maniglie non possono incrociarsi e l’esempio riporta [15, 15] sia per value sia per drag_value.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python, react
Ambito
frontend
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.