Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export interface FileUploadProps
/** A callback for when a selected file starts loading. */
onReadStarted?: (fileHandle: File) => void;
/** Text area text changed. */
onTextChange?: (text: string) => void;
onTextChange?: (event: React.ChangeEvent<HTMLTextAreaElement>, text: string) => void;
}

export const FileUpload: React.FunctionComponent<FileUploadProps> = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export interface FileUploadFieldProps extends Omit<React.HTMLProps<HTMLDivElemen
* of the file upload component. */
onTextAreaClick?: (event: React.MouseEvent<HTMLTextAreaElement, MouseEvent>) => void;
/** Text area text changed. */
onTextChange?: (text: string) => void;
onTextChange?: (event: React.ChangeEvent<HTMLTextAreaElement>, text: string) => void;
/** Placeholder string to display in the empty text area field. */
textAreaPlaceholder?: string;
}
Expand Down Expand Up @@ -114,8 +114,8 @@ export const FileUploadField: React.FunctionComponent<FileUploadFieldProps> = ({

...props
}: FileUploadFieldProps) => {
const onTextAreaChange = (newValue: string) => {
onTextChange?.(newValue);
const onTextAreaChange = (newValue: string, event: React.ChangeEvent<HTMLTextAreaElement>) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're following the convention that event is first for these functions, should the order of these parameters be swapped?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I debated how I wanted to approach this. Since the onChange of TextArea that this gets passed into is still on the todo list of the param adding epic I went with just leaving this internal function in the order that it's in, but I could update the order here and just swap them in the onChange, either way works if you have a preference.

onTextChange?.(event, newValue);
};
return (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const CustomPreviewFileUpload: React.FunctionComponent = () => {
hasPlaceholderText
]);

const handleTextAreaChange = (value: string) => {
const handleTextAreaChange = (_event: React.ChangeEvent<HTMLTextAreaElement>, value: string) => {
setValue(value);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ export const SimpleTextFileUpload: React.FunctionComponent = () => {
setFilename(file.name);
};

const handleTextOrDataChange = (value: string) => {
const handleTextChange = (_event: React.ChangeEvent<HTMLTextAreaElement>, value: string) => {
setValue(value);
};

const handleDataChange = (value: string) => {
setValue(value);
};

Expand All @@ -35,8 +39,8 @@ export const SimpleTextFileUpload: React.FunctionComponent = () => {
filename={filename}
filenamePlaceholder="Drag and drop a file or upload one"
onFileInputChange={handleFileInputChange}
onDataChange={handleTextOrDataChange}
onTextChange={handleTextOrDataChange}
onDataChange={handleDataChange}
onTextChange={handleTextChange}
onReadStarted={handleFileReadStarted}
onReadFinished={handleFileReadFinished}
onClearClick={handleClear}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ export const TextFileWithEditsAllowed: React.FunctionComponent = () => {
setFilename(file.name);
};

const handleTextOrDataChange = (value: string) => {
const handleTextChange = (_event: React.ChangeEvent<HTMLTextAreaElement>, value: string) => {
setValue(value);
};

const handleDataChange = (value: string) => {
setValue(value);
};

Expand All @@ -35,8 +39,8 @@ export const TextFileWithEditsAllowed: React.FunctionComponent = () => {
filename={filename}
filenamePlaceholder="Drag and drop a file or upload one"
onFileInputChange={handleFileInputChange}
onDataChange={handleTextOrDataChange}
onTextChange={handleTextOrDataChange}
onDataChange={handleDataChange}
onTextChange={handleTextChange}
onReadStarted={handleFileReadStarted}
onReadFinished={handleFileReadFinished}
onClearClick={handleClear}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export const TextFileUploadWithRestrictions: React.FunctionComponent = () => {
setFilename(file.name);
};

const handleTextOrDataChange = (value: string) => {
const handleTextChange = (_event: React.ChangeEvent<HTMLTextAreaElement>, value: string) => {
setValue(value);
};

const handleDataChange = (value: string) => {
setValue(value);
};

Expand Down Expand Up @@ -43,8 +47,8 @@ export const TextFileUploadWithRestrictions: React.FunctionComponent = () => {
filename={filename}
filenamePlaceholder="Drag and drop a file or upload one"
onFileInputChange={handleFileInputChange}
onDataChange={handleTextOrDataChange}
onTextChange={handleTextOrDataChange}
onDataChange={handleDataChange}
onTextChange={handleTextChange}
onReadStarted={handleFileReadStarted}
onReadFinished={handleFileReadFinished}
onClearClick={handleClear}
Expand Down