-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Update/block mover accessibility #949
Changes from 14 commits
2e88523
4a4842d
f5980cb
db9c6de
6f5efac
8a18c28
e05e085
4ee6216
b338c3a
603662d
0edfd88
7cdab46
2ef417d
1479fb7
716b973
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export default function( { typeTitle, position, isFirst, isLast, dir } ) { | ||
const prefix = 'Move "' + typeTitle + '" block from position ' + position; | ||
const errorPrefix = 'Block "' + typeTitle + '"'; | ||
let title = ''; | ||
|
||
if ( isFirst && isLast ) { | ||
title = errorPrefix + ' is the only block, and cannot be moved'; | ||
} else if ( dir > 0 ) { | ||
// moving down | ||
title = ( ! isLast ) ? | ||
prefix + ' down to position ' + ( position + 1 ) : | ||
errorPrefix + ' is at the end of the content and can’t be moved down'; | ||
} else { | ||
// moving up | ||
title = ( ! isFirst ) ? | ||
prefix + ' up to position ' + ( position - 1 ) : | ||
errorPrefix + ' is at the beginning of the content and can’t be moved up'; | ||
} | ||
|
||
return title; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { expect } from 'chai'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import generateOrderTitle from '../generate-order-title'; | ||
|
||
describe( 'block mover', () => { | ||
describe( 'generateOrderTitle', () => { | ||
const typeTitle = 'TestType'; | ||
|
||
it( 'Should generate a title for the first item moving up', () => { | ||
expect( generateOrderTitle( { | ||
typeTitle, | ||
position: 1, | ||
isFirst: true, | ||
isLast: false, | ||
dir: -1, | ||
} ) ).to.equal( | ||
'Block "' + typeTitle + '" is at the beginning of the content and can’t be moved up' | ||
); | ||
} ); | ||
|
||
it( 'Should generate a title for the last item moving down', () => { | ||
expect( generateOrderTitle( { | ||
typeTitle, | ||
position: 1, | ||
isFirst: false, | ||
isLast: true, | ||
dir: 1, | ||
} ) ).to.equal( | ||
'Block "' + typeTitle + '" is at the end of the content and can’t be moved down' | ||
); | ||
} ); | ||
|
||
it( 'Should generate a title for the second item moving up', () => { | ||
expect( generateOrderTitle( { | ||
typeTitle, | ||
position: 2, | ||
isFirst: false, | ||
isLast: false, | ||
dir: -1, | ||
} ) ).to.equal( | ||
'Move "' + typeTitle + '" block from position 2 up to position 1' | ||
); | ||
} ); | ||
|
||
it( 'Should generate a title for the second item moving down', () => { | ||
expect( generateOrderTitle( { | ||
typeTitle, | ||
position: 2, | ||
isFirst: false, | ||
isLast: false, | ||
dir: 1, | ||
} ) ).to.equal( | ||
'Move "' + typeTitle + '" block from position 2 down to position 3' | ||
); | ||
} ); | ||
|
||
it( 'Should generate a title for the only item in the list', () => { | ||
expect( generateOrderTitle( { | ||
typeTitle, | ||
position: 1, | ||
isFirst: true, | ||
isLast: true, | ||
dir: 1, | ||
} ) ).to.equal( | ||
'Block "' + typeTitle + '" is the only block, and cannot be moved' | ||
); | ||
} ); | ||
} ); | ||
} ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,7 +232,7 @@ class VisualEditorBlock extends wp.element.Component { | |
tabIndex="0" | ||
{ ...wrapperProps } | ||
> | ||
{ ( showUI || isHovered ) && <BlockMover uids={ [ block.uid ] } /> } | ||
{ ( showUI || isHovered ) && <BlockMover uid={ block.uid } order={ this.props.order } /> } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can't make this change because the block mover is also used with several blocks (multi-selection). See the second usage in this exact same file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, thank you for spotting and apologies for not seeing it myself! I'll look into amending this tonight and allowing for the case of multiple blocks. Likely the string will just have to read something like "Move n blocks {down|up} by one place". |
||
{ showUI && | ||
<CSSTransitionGroup | ||
transitionName={ { appear: 'is-appearing', appearActive: 'is-appearing-active' } } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered using an early-abort style instead of doing more nesting and mutation of
title
?