Skip to content
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
14 changes: 8 additions & 6 deletions packages/components/src/placeholder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,14 @@ function Placeholder( {
<Icon icon={ icon } />
{ label }
</div>
{ !! instructions && (
<div className="components-placeholder__instructions">
{ instructions }
</div>
) }
<div className={ fieldsetClasses }>{ children }</div>
<fieldset className={ fieldsetClasses }>
{ !! instructions && (
<legend className="components-placeholder__instructions">
{ instructions }
</legend>
) }
{ children }
</fieldset>
</div>
);
}
Expand Down
12 changes: 12 additions & 0 deletions packages/components/src/placeholder/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@
}
}

// Overrides for browser and editor fieldset styles.
.components-placeholder__fieldset.components-placeholder__fieldset {
border: none;
padding: 0;

.components-placeholder__instructions {
padding: 0;
font-weight: normal;
font-size: 1em;
}
}

.components-placeholder__fieldset.is-column-layout,
.components-placeholder__fieldset.is-column-layout form {
flex-direction: column;
Expand Down
19 changes: 18 additions & 1 deletion packages/components/src/placeholder/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,31 @@ describe( 'Placeholder', () => {
const element = <div>Fieldset</div>;
const placeholder = shallow( <Placeholder children={ element } /> );
const placeholderFieldset = placeholder.find(
'.components-placeholder__fieldset'
'fieldset.components-placeholder__fieldset'
);
const child = placeholderFieldset.childAt( 0 );

expect( placeholderFieldset.exists() ).toBe( true );
expect( child.matchesElement( element ) ).toBe( true );
} );

it( 'should display a legend if instructions are passed', () => {
const element = <div>Fieldset</div>;
const instructions = 'Choose an option.';
const placeholder = shallow(
<Placeholder
children={ element }
instructions={ instructions }
/>
);
const placeholderLegend = placeholder.find(
'legend.components-placeholder__instructions'
);

expect( placeholderLegend.exists() ).toBe( true );
expect( placeholderLegend.text() ).toEqual( instructions );
} );

it( 'should add an additional className to the top container', () => {
const placeholder = shallow(
<Placeholder className="wp-placeholder" />
Expand Down