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

Quote Block: Fixing focus transfer between citation and content #5100

Merged
merged 2 commits into from
Feb 16, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions blocks/library/pullquote/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
}

.wp-block-pullquote {
cite {
display: block;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This just increases the click area of the citation to the whole line (width: 100%)

Copy link
Member

Choose a reason for hiding this comment

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

This kind of tells me that we shouldn't be using cite for this... :)

}

cite .blocks-rich-text__tinymce[data-is-empty="true"]:before {
font-size: 14px;
font-family: $default-font;
Expand Down
4 changes: 4 additions & 0 deletions blocks/library/quote/editor.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
.wp-block-quote {
margin: 0;

cite {
display: block;
}
}

.wp-block-quote:not(.is-large) {
Expand Down
4 changes: 3 additions & 1 deletion blocks/library/quote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ export const settings = {
} )( ( { attributes, setAttributes, isSelected, mergeBlocks, onReplace, className, editable, setState } ) => {
const { align, value, citation, style } = attributes;
const containerClassname = classnames( className, style === 2 ? 'is-large' : '' );
const onSetActiveEditable = ( newEditable ) => () => setState( { editable: newEditable } );
const onSetActiveEditable = ( newEditable ) => () => {
setState( { editable: newEditable } );
};

return [
isSelected && (
Expand Down
4 changes: 3 additions & 1 deletion blocks/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,9 @@ export class RichText extends Component {
!! this.editor &&
this.props.tagName === prevProps.tagName &&
this.props.value !== prevProps.value &&
this.props.value !== this.savedContent
this.props.value !== this.savedContent &&
! isEqual( this.props.value, prevProps.value ) &&
! isEqual( this.props.value, this.savedContent )
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the real fix. I removed this as part of #4955 but it's necessary to avoid unnecessarily content updates. I don't see any performance loss in adding this and it could even improve performance because we don't use those TinyMCE functions setBookmark and setContent constantly

Copy link
Member

Choose a reason for hiding this comment

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

@youknowriad I feel like we removed and added this a few times I the last year now. :) Maybe worth leaving a comment?

Copy link
Member

Choose a reason for hiding this comment

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

(I was surprised to see these lines again.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call 👍

) {
this.updateContent();
}
Expand Down