Skip to content

Commit

Permalink
Merge pull request #2107 from dxc-technology/Mil4n0r/fix_whitespaces_…
Browse files Browse the repository at this point in the history
…fileinput

Added fix for whitespaces not displaying in filename
  • Loading branch information
GomezIvann authored Oct 25, 2024
2 parents 718e29e + 0d6556b commit cd11148
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions packages/lib/src/file-input/FileInput.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@ const file4 = new File(["file4"], "file4file4file4file4file4file4file4file4file4
const file5 = new File(["file5"], "file5file5file5file5file5file5file5file5file5.mp4", {
type: "video",
});
const fileWithSpaces = new File(["fileSpaces"], " f i l e s p a c e s.png", { type: "image/png" });

const fileExample = [
{
file: file1,
},
];

const fileWithSpacesExample = [
{
file: fileWithSpaces,
},
];

const fileExampleError = [
{
error: "Error message",
Expand Down Expand Up @@ -134,6 +141,16 @@ export const Chromatic = () => (
callbackFile={() => {}}
/>
</ExampleContainer>
<ExampleContainer>
<Title title="Single file (with spaces)" theme="light" level={4} />
<DxcFileInput
label="File input"
helperText="Please select files"
value={fileWithSpacesExample}
multiple={false}
callbackFile={() => {}}
/>
</ExampleContainer>
<ExampleContainer>
<Title title="Invalid single file" theme="light" level={4} />
<DxcFileInput
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/file-input/FileItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const FileName = styled.span`
font-size: ${(props) => props.theme.fileItemFontSize};
font-weight: ${(props) => props.theme.fileItemFontWeight};
line-height: ${(props) => props.theme.fileItemLineHeight};
white-space: nowrap;
white-space: pre;
overflow: hidden;
text-overflow: ellipsis;
`;
Expand Down

0 comments on commit cd11148

Please sign in to comment.