mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
✨ Add a new local “isBusy” flag for busy-wrapper
This commit is contained in:
parent
1e26852aa1
commit
827e08d91f
1 changed files with 4 additions and 2 deletions
|
@ -24,6 +24,7 @@ const BusyContext = createContext( false );
|
||||||
* @param {boolean} props.busySpinner - Allows disabling the spinner in busy-state.
|
* @param {boolean} props.busySpinner - Allows disabling the spinner in busy-state.
|
||||||
* @param {string} props.className - Additional class names for the wrapper.
|
* @param {string} props.className - Additional class names for the wrapper.
|
||||||
* @param {Function} props.onBusy - Callback to process child props when busy.
|
* @param {Function} props.onBusy - Callback to process child props when busy.
|
||||||
|
* @param {boolean} props.isBusy - Optional. Additional condition to determine if the component is busy.
|
||||||
*/
|
*/
|
||||||
const BusyStateWrapper = ( {
|
const BusyStateWrapper = ( {
|
||||||
children,
|
children,
|
||||||
|
@ -31,11 +32,12 @@ const BusyStateWrapper = ( {
|
||||||
busySpinner = true,
|
busySpinner = true,
|
||||||
className = '',
|
className = '',
|
||||||
onBusy = () => ( { disabled: true } ),
|
onBusy = () => ( { disabled: true } ),
|
||||||
|
isBusy = false,
|
||||||
} ) => {
|
} ) => {
|
||||||
const { isBusy } = CommonHooks.useBusyState();
|
const { isBusy: globalIsBusy } = CommonHooks.useBusyState();
|
||||||
const hasBusyParent = useContext( BusyContext );
|
const hasBusyParent = useContext( BusyContext );
|
||||||
|
|
||||||
const isBusyComponent = isBusy && enabled;
|
const isBusyComponent = ( isBusy || globalIsBusy ) && enabled;
|
||||||
const showSpinner = busySpinner && isBusyComponent && ! hasBusyParent;
|
const showSpinner = busySpinner && isBusyComponent && ! hasBusyParent;
|
||||||
|
|
||||||
const wrapperClassName = classNames( 'ppcp-r-busy-wrapper', className, {
|
const wrapperClassName = classNames( 'ppcp-r-busy-wrapper', className, {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue