plotly / plotly/dash

[BUG] Upload component applying styles on Drag/Drop

Open
#3,376 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
24.4k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
13

Description

When using Drag/Drop to place files into an Upload component accepting only .obj or .XLS (seperate inputs for both filetypes) Edge display always the error border on the upload. Firefox diplaying the error broder when the obj File into the input with the accepting file Type .obj.

Describe your context
Running on Windows with Python 3.12

dash                      3.1.0
dash-bootstrap-components 2.0.3
  • if frontend related, tell us your Browser, Version and OS

    • OS: Windows
    • Browser: Edge / Firefox
    • Version: 138.0.3351.95 / 128.12.0esr

Describe the bug

Wrong colors on input borders when dropping Files with correct Filetype (obj / XLSX) setting on Edge always "red" for all input files and types. On Firefox only setting red border style for obj files.

Expected behavior

Show specified color in style_active attribute of input component


dcc.Upload(
    id=f"{id_str}-upload-data",
    children=html.Div(
        [
            "Drag und drop oder klicken um Datei für upload auszuwählen."
        ]
    ),
    style={
        "width": "100%",
        "height": "60px",
        "borderWidth": "2px",
        "borderStyle": "solid",
        "borderRadius": "5px",
        "borderColor": "var(--bs-primary-border-subtle)",
        "textAlign": "center",
    },
    multiple=False,
    accept=file_extension,
    className="align-content-center",
    style_active={
        "borderStyle": "solid",
        "borderColor": "var(--bs-success)",
    },
    style_reject={
        "borderStyle": "solid",
        "borderColor": "var(--bs-danger)",
    },
),

File type get set as "text/csv,application/vnd.ms-excel" for XLS inputs and .obj

Contributor guide

Open the contributing guide

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 with the dcc.Upload reproduction and its accept, style, style_active, and style_reject settings, then reproduce the drag-and-drop behavior in the reported Edge and Firefox versions. Done means valid .obj and XLS/XLSX drops show the active styling rather than the reject border, with invalid files still showing the reject styling.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.