@awsui/components-react
Version:
On July 19th, 2022, we launched [Cloudscape Design System](https://cloudscape.design). Cloudscape is an evolution of AWS-UI. It consists of user interface guidelines, front-end components, design resources, and development tools for building intuitive, en
23 lines • 1.11 kB
JavaScript
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { useEffect, useRef } from 'react';
import { useDebounceCallback } from '../internal/hooks/use-debounce-callback';
// Debounce delay for live region (based on testing with VoiceOver)
const LIVE_REGION_DELAY = 2000;
export default function useDebounceSearchResultCallback({ searchQuery, countText, loading, announceCallback, }) {
const loadingRef = useRef(loading);
// announceCallback is called when:
// - For sync filters: on searchQuery/countText changes.
// - For async filters: on searchQuery/countText when loading completed and countText exists.
const debounceLiveAnnouncement = useDebounceCallback(() => {
if (!countText || loadingRef.current) {
return;
}
announceCallback();
}, LIVE_REGION_DELAY);
useEffect(() => {
loadingRef.current = loading;
debounceLiveAnnouncement();
}, [searchQuery, countText, loading, debounceLiveAnnouncement]);
}
//# sourceMappingURL=use-debounce-search-result-callback.js.map