Skip to content

Commit

Permalink
fix: Removes files prop and updates focus state outline
Browse files Browse the repository at this point in the history
  • Loading branch information
Katie George committed Nov 25, 2024
1 parent d8b1dc1 commit 2d8d2db
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
1 change: 0 additions & 1 deletion pages/button-group/test.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export default function ButtonGroupPage() {
type: 'file-input',
id: 'file-input',
text: 'Choose files',
value: files,
multiple: true,
},
],
Expand Down
1 change: 0 additions & 1 deletion pages/prompt-input/simple.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ export default function PromptInputPage() {
type: 'file-input',
id: 'files',
text: 'Upload files',
value: files,
multiple: true,
},
{
Expand Down
10 changes: 7 additions & 3 deletions src/button-group/file-input-item.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import React, { forwardRef } from 'react';
import React, { forwardRef, useState } from 'react';
import clsx from 'clsx';

import { FileInputProps } from '../file-input/interfaces.js';
Expand All @@ -24,6 +24,7 @@ const FileInputItem = forwardRef(
},
ref: React.Ref<FileInputProps.Ref>
) => {
const [files, setFiles] = useState<File[]>([]);
const containerRef = React.useRef<HTMLDivElement>(null);

Check warning on line 28 in src/button-group/file-input-item.tsx

View check run for this annotation

Codecov / codecov/patch

src/button-group/file-input-item.tsx#L26-L28

Added lines #L26 - L28 were not covered by tests

const canShowTooltip = Boolean(showTooltip);
Expand All @@ -34,8 +35,11 @@ const FileInputItem = forwardRef(
ariaLabel={item.text}
accept={item.accept}
multiple={item.multiple}
value={item.value}
onChange={event => fireCancelableEvent(onItemClick, { id: item.id, files: event.detail.value })}
value={files}
onChange={event => {
fireCancelableEvent(onItemClick, { id: item.id, files: event.detail.value });
setFiles(event.detail.value);

Check warning on line 41 in src/button-group/file-input-item.tsx

View check run for this annotation

Codecov / codecov/patch

src/button-group/file-input-item.tsx#L39-L41

Added lines #L39 - L41 were not covered by tests
}}
ref={ref}
data-testid={item.id}
dataItemId={item.id}
Expand Down
1 change: 0 additions & 1 deletion src/button-group/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ export namespace ButtonGroupProps {
type: 'file-input';
id: string;
text: string;
value: File[];
accept?: string;
multiple?: boolean;
}
Expand Down
7 changes: 6 additions & 1 deletion src/file-input/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
.file-input-button {
@include focus-visible.when-visible-unfocused {
&.force-focus-outline {
@include styles.focus-highlight(awsui.$space-button-focus-outline-gutter);
@include styles.focus-highlight(
(
'vertical': awsui.$space-button-icon-focus-outline-gutter-vertical,
'horizontal': awsui.$space-button-focus-outline-gutter,
)
);
}
}
}

0 comments on commit 2d8d2db

Please sign in to comment.