Skip to content

Commit f97d7af

Browse files
tyxlaandrewserong
andauthored
Media Fields: Fix filename field truncation (WordPress#75091)
* Media Fields: Fix filename field truncation * Fix test Co-authored-by: tyxla <tyxla@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
1 parent 9a9900a commit f97d7af

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/media-fields/src/filename/test/view.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ describe( 'FileNameView', () => {
4949

5050
// Verify the full filename text is accessible to users
5151
// (the component handles truncation via Truncate/Tooltip, but the text is still present)
52-
expect( screen.getByText( longFilename ) ).toBeInTheDocument();
52+
expect(
53+
screen.getByText( longFilename.slice( 0, 15 ) + '…' )
54+
).toBeInTheDocument();
5355
} );
5456
} );
5557

packages/media-fields/src/filename/view.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export default function FileNameView( {
3131

3232
return fileName.length > TRUNCATE_LENGTH ? (
3333
<Tooltip text={ fileName }>
34-
<Truncate>{ fileName }</Truncate>
34+
<Truncate limit={ TRUNCATE_LENGTH } ellipsizeMode="tail">
35+
{ fileName }
36+
</Truncate>
3537
</Tooltip>
3638
) : (
3739
<>{ fileName }</>

0 commit comments

Comments
 (0)