fix: prevent unintended CSS inheritance on DropZone content #885
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.
This pull request addresses a potential styling issue introduced by the recent change where DropZones are now wrapped in a
<div>
. Previously, users could directly style the container element of a component that included a DropZone (e.g.,<section className="sectionBlock"><DropZone /></section>
). The new wrapping<div>
can cause unexpected inheritance of styles from parent elements, breaking existing layouts.Problem:
With the new
<div>
wrapper, CSS rules targeting the parent container (e.g.,section.sectionBlock
) now also apply to the wrapping<div>
and subsequently, to the content rendered within the DropZone. This can lead to unintended styling changes.Example:
Consider the following component configuration:
Old Puck Version (Correct Behavior):
New Puck Version (Incorrect Behavior - Unintended Styling):
In the new version, styles applied to
section.sectionBlock
might unintentionally affect the content within the DropZone due to the intermediate<div>
.Solution:
This pull request introduces the
as
prop to the DropZone component. This prop allows users to specify the HTML element to be used as the DropZone's container. By settingas="section"
, users can maintain the original structure and prevent unintended style inheritance.Example Usage:
This change allows users to have more control over the styling of their DropZones and ensures backward compatibility with existing component configurations. It avoids breaking existing layouts that rely on specific CSS rules targeting parent containers.