A failed upload from a file drop or paste leaves a stuck "Loading..." block
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 35/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Estagnada
- Stack de tecnologia
- react, typescript
- Domínio
- frontend, full-stack
Direção de pesquisa
The report identifies handleFileInsertion, editor.uploadFile, and editor.updateBlock, but gives no file path or test name. Start by locating handleFileInsertion and tracing the drop and paste upload flow. Reproduce with uploadFile resolving to an empty string and with a rejected promise; done means a failed upload no longer leaves a Loading block and rejections are handled. An open linked pull request (#3247) already addresses this issue.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
What’s broken?
When uploadFile fails for a file that was dropped or pasted into the editor, the inserted file block keeps showing "Loading..." forever. The user has to delete it by hand.
handleFileInsertion inserts a file block, awaits editor.uploadFile(file, blockId) and then always calls editor.updateBlock(blockId, { props: { url } }).
- If
uploadFileresolves with""to report a failure, the props don't change, so the block doesn't render again. Its vanilla render replaced the "Add file" button with.bn-file-loading-previewinonUploadStart, and nothing restores it when the upload ends. - If
uploadFilerejects, the rejection isn't caught.updateBlocknever runs, the promise rejection is unhandled, and the block stays on "Loading..." as well.
The file panel's upload tab doesn't show this, because it sets name together with url. The block renders again and offers "Add file".
What did you expect to happen?
A failed upload doesn't leave a stuck placeholder. The block is either removed or goes back to its "Add file" state, and a rejected uploadFile is caught. A documented way for uploadFile to report a failure would help too.
Steps to reproduce
- Create an editor whose
uploadFilefails:const editor = useCreateBlockNote({ uploadFile: () => Promise.resolve(""), }); - Drag any file from your computer into the editor, or paste one.
- A file block showing "Loading..." stays in the document.
With uploadFile: () => Promise.reject(new Error("rejected")) the block stays as well, and the console shows an unhandled promise rejection.
BlockNote version
@blocknote/core, @blocknote/react, @blocknote/mantine 0.55.0
Environment
No response
Additional context
We work around it by listening to onUploadEnd and, in a timeout after BlockNote's updateBlock, removing the block if it still renders .bn-file-loading-preview.
Contribution
- I'd be interested in contributing a fix for this issue
Sponsor
- I'm a sponsor and would appreciate if you could look into this sooner than later 💖
- Linguagem predominante
- TypeScript
- Estrelas
- 10.3k
- Forks
- 780
- Merge médio
- 3d 6h
- PRs com merge (30d)
- 48
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de TypeCellOS/BlockNote
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
TypeCellOS/BlockNote#2949 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
a11y
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
TypeCellOS/BlockNote#2855 ·
Mantenedores costumam responder em até 1 dia
-
a11y
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
TypeCellOS/BlockNote#2829 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Comment thread actions: hover-only controls and unlabeled buttons in ThreadsSidebaTalvez já em andamento @matthewlipski assumiu há 2 dias. Abertaa11y
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
TypeCellOS/BlockNote#2824 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 58/100
TypeCellOS/BlockNote#3245 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de TypeCellOS/BlockNote
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
awesome-dsh-plugin/awesome-dsh-plugin#9184 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
farion1231/cc-switch#8829 ·
Mantenedores costumam responder em até 1 dia
-
[core-client] Remove unused hand-maintained transport helpers after the definition-table cutoverAbertadoc-audit enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100