-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Select): enforce content update after render (#156)
* fix(Select): enforce content update after render * style(Select): format * refactor(Select): request content update only if the renderer is provided * style(Select): format * test(Select): add more tests * fix(Select): watch children prop too * test(Select): add test for children renderer * Update test/Select.spec.tsx Co-authored-by: Sergey Vinogradov <[email protected]> --------- Co-authored-by: Sergey Vinogradov <[email protected]>
- Loading branch information
Showing
8 changed files
with
304 additions
and
501 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { type ForwardedRef, type RefCallback, useCallback } from 'react'; | ||
|
||
export default function useMergedRefs<T extends HTMLElement>(...refs: ReadonlyArray<ForwardedRef<T>>): RefCallback<T> { | ||
return useCallback((element: T) => { | ||
refs.forEach((ref) => { | ||
if (typeof ref === 'function') { | ||
ref(element); | ||
} else if (!!ref) { | ||
ref.current = element; | ||
} | ||
}); | ||
}, refs); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
declare namespace Chai { | ||
interface PromisedAssertion { | ||
text(text: string | string[]): PromisedAssertion; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { waitFor } from '@testing-library/react'; | ||
|
||
export async function findByQuerySelector<K extends keyof HTMLElementTagNameMap>( | ||
query: K, | ||
container?: Document | HTMLElement, | ||
): Promise<HTMLElementTagNameMap[K]>; | ||
export async function findByQuerySelector<E extends Element = Element>( | ||
query: string, | ||
container?: Document | HTMLElement, | ||
): Promise<E>; | ||
export async function findByQuerySelector( | ||
query: string, | ||
container: Document | HTMLElement = document, | ||
): Promise<Element> { | ||
return await waitFor(() => container.querySelector(query)!); | ||
} |