File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed
e2e/__tests__/app-impress
impress/src/features/docs/doc-editor/components/BlockNoteToolBar Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ and this project adheres to
26
26
- ♿ remove redundant aria-label on hidden icons and update tests #1432
27
27
- ♿ improve semantic structure and aria roles of leftpanel #1431
28
28
- ♿ add default background to left panel for better accessibility #1423
29
- - ♿ restyle checked checkboxes: removing strikethrough #1439
29
+ - ♿ restyle checked checkboxes: removing strikethrough #1439
30
30
- ♿ add h1 for SR on 40X pages and remove alt texts #1438
31
31
- ♿ update labels and shared document icon accessibility #1442
32
32
@@ -38,6 +38,7 @@ and this project adheres to
38
38
- 🐛(frontend) fix legacy role computation #1376
39
39
- 🛂(frontend) block editing title when not allowed #1412
40
40
- 🐛(frontend) scroll back to top when navigate to a document #1406
41
+ - 🐛(frontend) fix attachment download filename #1447
41
42
- 🐛(frontend) exclude h4-h6 headings from table of contents #1441
42
43
- 🔒(frontend) prevent readers from changing callout emoji #1449
43
44
Original file line number Diff line number Diff line change @@ -846,6 +846,7 @@ test.describe('Doc Editor', () => {
846
846
847
847
await page . getByText ( 'Add PDF' ) . click ( ) ;
848
848
const fileChooserPromise = page . waitForEvent ( 'filechooser' ) ;
849
+ const downloadPromise = page . waitForEvent ( 'download' ) ;
849
850
await page . getByText ( 'Upload file' ) . click ( ) ;
850
851
const fileChooser = await fileChooserPromise ;
851
852
@@ -866,5 +867,12 @@ test.describe('Doc Editor', () => {
866
867
867
868
await expect ( pdfEmbed ) . toHaveAttribute ( 'type' , 'application/pdf' ) ;
868
869
await expect ( pdfEmbed ) . toHaveAttribute ( 'role' , 'presentation' ) ;
870
+
871
+ // Check download with original filename
872
+ await page . locator ( '.bn-block-content[data-content-type="pdf"]' ) . click ( ) ;
873
+ await page . locator ( '[data-test="downloadfile"]' ) . click ( ) ;
874
+
875
+ const download = await downloadPromise ;
876
+ expect ( download . suggestedFilename ( ) ) . toBe ( 'test-pdf.pdf' ) ;
869
877
} ) ;
870
878
} ) ;
Original file line number Diff line number Diff line change @@ -76,11 +76,23 @@ export const FileDownloadButton = ({
76
76
77
77
if ( ! url . includes ( '-unsafe' ) ) {
78
78
const blob = ( await exportResolveFileUrl ( url ) ) as Blob ;
79
- downloadFile ( blob , url . split ( '/' ) . pop ( ) || 'file' ) ;
79
+ downloadFile (
80
+ blob ,
81
+ fileBlock . props . name || url . split ( '/' ) . pop ( ) || 'file' ,
82
+ ) ;
80
83
} else {
81
84
const onConfirm = async ( ) => {
82
85
const blob = ( await exportResolveFileUrl ( url ) ) as Blob ;
83
- downloadFile ( blob , url . split ( '/' ) . pop ( ) || 'file (unsafe)' ) ;
86
+
87
+ const baseName =
88
+ fileBlock . props . name || url . split ( '/' ) . pop ( ) || 'file' ;
89
+
90
+ const regFindLastDot = / ( \. [ ^ / . ] + ) $ / ;
91
+ const unsafeName = baseName . includes ( '.' )
92
+ ? baseName . replace ( regFindLastDot , '-unsafe$1' )
93
+ : baseName + '-unsafe' ;
94
+
95
+ downloadFile ( blob , unsafeName ) ;
84
96
} ;
85
97
86
98
open ( onConfirm ) ;
@@ -100,6 +112,7 @@ export const FileDownloadButton = ({
100
112
< >
101
113
< Components . FormattingToolbar . Button
102
114
className = "bn-button --docs--editor-file-download-button"
115
+ data-test = "downloadfile"
103
116
label = {
104
117
dict . formatting_toolbar . file_download . tooltip [ fileBlock . type ] ||
105
118
dict . formatting_toolbar . file_download . tooltip [ 'file' ]
You can’t perform that action at this time.
0 commit comments