-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix v11.0.0 types that removed the default export #1406
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 @@ | ||
--- | ||
'focus-trap-react': patch | ||
--- | ||
|
||
Fix missing default export in typings; deprecate default export; add named export in code ([#1396](https://github.com/focus-trap/focus-trap-react/issues/1396)) |
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
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
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
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
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 |
---|---|---|
@@ -1,14 +1,56 @@ | ||
import { Options as FocusTrapOptions } from 'focus-trap'; | ||
import * as React from 'react'; | ||
|
||
export interface FocusTrapProps extends React.AllHTMLAttributes<any> { | ||
/** | ||
* __Single container child__ for the trap. Use `containerElements` instead | ||
* if you need a trap with multiple containers. | ||
*/ | ||
children?: React.ReactNode; | ||
|
||
/** | ||
* By default, the trap will be active when it mounts, so it's activated by | ||
* mounting, and deactivated by unmounting. Use this prop to control when | ||
* it's active while it's mounted, or if it's initially inactive. | ||
*/ | ||
active?: boolean; | ||
|
||
/** | ||
* To pause or unpause the trap while it's `active`. Primarily for use when | ||
* you need to manage multiple traps in the same view. When paused, the trap | ||
* retains its various event listeners, but ignores all events. | ||
*/ | ||
paused?: boolean; | ||
|
||
/** | ||
* See Focus-trap's [createOptions](https://github.com/focus-trap/focus-trap?tab=readme-ov-file#createoptions) | ||
* for more details on available options. | ||
*/ | ||
focusTrapOptions?: FocusTrapOptions; | ||
|
||
/** | ||
* If specified, these elements will be used as the boundaries for the | ||
* trap, __instead of the child__ specified in `children` (though | ||
* `children` will still be rendered). | ||
*/ | ||
containerElements?: Array<HTMLElement>; | ||
} | ||
|
||
export declare class FocusTrap extends React.Component<FocusTrapProps> { } | ||
|
||
/** | ||
* Default export of the FocusTrap component. | ||
* @deprecated 🔺 Use the named import `{ FocusTrap }` instead. | ||
* @description 🔺 The default export will be removed in a future release. Migrate to the named | ||
* import `{ FocusTrap }` today to ensure future compatibility. | ||
*/ | ||
declare namespace FocusTrap { | ||
export interface Props extends React.AllHTMLAttributes<any> { | ||
children?: React.ReactNode; | ||
active?: boolean; | ||
paused?: boolean; | ||
focusTrapOptions?: FocusTrapOptions; | ||
containerElements?: Array<HTMLElement>; | ||
} | ||
export type Props = FocusTrapProps; | ||
} | ||
|
||
export declare class FocusTrap extends React.Component<FocusTrap.Props> { } | ||
/** | ||
* @deprecated 🔺 Use the named import `{ FocusTrap }` instead. | ||
* @description 🔺 The default export will be removed in a future release. Migrate to the named | ||
* import `{ FocusTrap }` today to ensure future compatibility. | ||
*/ | ||
export default FocusTrap; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, why extend
React.AllHTMLAttributes
here? I know it was done in earlier releases as well, but as far as I can see, none of the normal HTML attributes get used for anything. For example if I useThen there is no type error, but the class name "myFocusTrap" doesn't get applied to any element.
Wouldn't it be better to remove this altogether?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just been like that "forever" (before my time leading this project) but now that you point this out, you're totally right: There's no point in having this extension because
<FocusTrap>
doesn't render to anything, and doesn't reflect those extra HTML props onto anything either.And it should be safe to remove that because setting something like
className
would have never done anything anyway, so I would expect nearly no one is doing this today anyway.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mathias-S PR updated!