Skip to content
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 updateSlot missing from default SlotFillContext #23108

Merged
merged 4 commits into from
Jun 13, 2020
Merged
Show file tree
Hide file tree
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
Expand Up @@ -7,6 +7,7 @@ const SlotFillContext = createContext( {
slots: {},
fills: {},
registerSlot: () => {},
updateSlot: () => {},
unregisterSlot: () => {},
registerFill: () => {},
unregisterFill: () => {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ function useSlotRegistry() {
slots,
fills,
registerSlot,
updateSlot,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was also missing from the React memo deps, although it wasn't making any difference.

unregisterSlot,
registerFill,
unregisterFill,
Expand Down
14 changes: 14 additions & 0 deletions packages/components/src/slot-fill/test/__snapshots__/slot.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Slot bubblesVirtually false should not break without a Provider 1`] = `
<div>
<div />
</div>
`;

exports[`Slot bubblesVirtually false should subsume another slot by the same name 1`] = `
<div>
<div
Expand Down Expand Up @@ -37,6 +43,14 @@ exports[`Slot bubblesVirtually false should unmount two slots with the same name
</div>
`;

exports[`Slot bubblesVirtually true should not break without a Provider 1`] = `
<div>
<div>
<div />
</div>
</div>
`;

exports[`Slot bubblesVirtually true should subsume another slot by the same name 1`] = `
<div>
<div
Expand Down
16 changes: 16 additions & 0 deletions packages/components/src/slot-fill/test/slot.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,22 @@ describe( 'Slot', () => {
);
expect( container ).toMatchSnapshot();
} );

it( 'should not break without a Provider', () => {
const { container } = render(
<>
<div>
<Slot
name="chicken"
bubblesVirtually={ bubblesVirtually }
/>
</div>
<Fill name="chicken" />
</>
);

expect( container ).toMatchSnapshot();
} );
}
);
} );