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

オープン
#3,935 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
python, react
領域
frontend

調査の方向性

dcc.RangeSlider の実装から始め、allowCross=False を指定した最小限の例を再現します。両方の updatemodes で、ポインター、キーボード、Home/End、直接入力の各インタラクションを追跡し、それぞれの経路についてカバレッジを見つけるか追加します。ハンドルが交差できず、例が value と drag_value の両方について [15, 15] を報告すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug P2 size: 1

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
主要言語
Python
スター
24.4k
フォーク
2.3k
平均マージ
2日 7時間
マージ済み PR(30日)
13

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

plotly/dash のほかの issue

plotly/dash の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。