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

Fixes the checkbox appearance #17571

Merged
merged 7 commits into from
Sep 27, 2019
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
10 changes: 4 additions & 6 deletions packages/e2e-tests/specs/taxonomies.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ describe( 'Taxonomies', () => {
return page.evaluate(
() => {
return Array.from( document.querySelectorAll(
'.editor-post-taxonomies__hierarchical-terms-input:checked'
'.editor-post-taxonomies__hierarchical-terms-choice .components-checkbox-control__input:checked'
draganescu marked this conversation as resolved.
Show resolved Hide resolved
) ).map( ( node ) => {
return node.parentElement.querySelector(
'label'
).innerText;
return node.parentElement.nextSibling.innerText;
} );
}
);
Expand Down Expand Up @@ -83,7 +81,7 @@ describe( 'Taxonomies', () => {
await page.click( '.editor-post-taxonomies__hierarchical-terms-submit' );

// Wait for the categories to load.
await page.waitForSelector( '.editor-post-taxonomies__hierarchical-terms-input:checked' );
await page.waitForSelector( '.editor-post-taxonomies__hierarchical-terms-choice .components-checkbox-control__input:checked' );

let selectedCategories = await getSelectCategories();

Expand All @@ -101,7 +99,7 @@ describe( 'Taxonomies', () => {
await page.reload();

// Wait for the categories to load.
await page.waitForSelector( '.editor-post-taxonomies__hierarchical-terms-input:checked' );
await page.waitForSelector( '.editor-post-taxonomies__hierarchical-terms-choice .components-checkbox-control__input:checked' );

selectedCategories = await getSelectCategories();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { get, unescape as unescapeString, without, find, some, invoke } from 'lo
*/
import { __, _x, _n, sprintf } from '@wordpress/i18n';
import { Component } from '@wordpress/element';
import { TreeSelect, withSpokenMessages, withFilters, Button } from '@wordpress/components';
import { CheckboxControl, TreeSelect, withSpokenMessages, withFilters, Button } from '@wordpress/components';
import { withSelect, withDispatch } from '@wordpress/data';
import { withInstanceId, compose } from '@wordpress/compose';
import apiFetch from '@wordpress/api-fetch';
Expand Down Expand Up @@ -55,9 +55,8 @@ class HierarchicalTermSelector extends Component {
};
}

onChange( event ) {
onChange( termId ) {
const { onUpdateTerms, terms = [], taxonomy } = this.props;
const termId = parseInt( event.target.value, 10 );
const hasTerm = terms.indexOf( termId ) !== -1;
const newTerms = hasTerm ?
without( terms, termId ) :
Expand Down Expand Up @@ -316,18 +315,16 @@ class HierarchicalTermSelector extends Component {
renderTerms( renderedTerms ) {
const { terms = [] } = this.props;
return renderedTerms.map( ( term ) => {
const id = `editor-post-taxonomies-hierarchical-term-${ term.id }`;
return (
<div key={ term.id } className="editor-post-taxonomies__hierarchical-terms-choice">
<input
id={ id }
className="editor-post-taxonomies__hierarchical-terms-input"
draganescu marked this conversation as resolved.
Show resolved Hide resolved
type="checkbox"
<CheckboxControl
checked={ terms.indexOf( term.id ) !== -1 }
value={ term.id }
onChange={ this.onChange }
onChange={ () => {
draganescu marked this conversation as resolved.
Show resolved Hide resolved
const termId = parseInt( term.id, 10 );
this.onChange( termId );
} }
label={ unescapeString( term.name ) }
/>
<label htmlFor={ id }>{ unescapeString( term.name ) }</label>
{ !! term.children.length && (
<div className="editor-post-taxonomies__hierarchical-terms-subchoices">
{ this.renderTerms( term.children ) }
Expand Down
4 changes: 0 additions & 4 deletions packages/editor/src/components/post-taxonomies/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
margin-bottom: 8px;
}

.editor-post-taxonomies__hierarchical-terms-input[type="checkbox"] {
margin-top: 0;
}

.editor-post-taxonomies__hierarchical-terms-subchoices {
margin-top: 8px;
margin-left: $panel-padding;
Expand Down