Skip to content
Open
Changes from all commits
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
@@ -1,13 +1,13 @@
/**
* Copyright IBM Corp. 2016, 2025
* Copyright IBM Corp. 2016, 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import cx from 'classnames';
import PropTypes from 'prop-types';
import React, { useRef, useState, type HTMLAttributes } from 'react';
import React, { useEffect, useRef, useState, type HTMLAttributes } from 'react';
import { matches, keys } from '../../internal/keyboard';
import { useId } from '../../internal/useId';
import { usePrefix } from '../../internal/usePrefix';
Expand Down Expand Up @@ -121,7 +121,6 @@ function FileUploaderButton({
}: FileUploaderButtonProps) {
const prefix = usePrefix();
const [labelText, setLabelText] = useState(ownerLabelText);
const [prevOwnerLabelText, setPrevOwnerLabelText] = useState(ownerLabelText);
const generatedId = useId();
const { current: inputId } = useRef(id || generatedId);
const inputNode = useRef<HTMLInputElement>(null);
Expand All @@ -134,11 +133,9 @@ function FileUploaderButton({
[`${prefix}--layout--size-${size}`]: size,
});

// Adjust label text state based on changes to the labelText prop
if (ownerLabelText !== prevOwnerLabelText) {
useEffect(() => {
setLabelText(ownerLabelText);
setPrevOwnerLabelText(ownerLabelText);
}
}, [ownerLabelText]);

function onClick(event) {
event.target.value = null;
Expand Down
Loading