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

Popover: Visually indicate focus effect on popover content #3057

Merged
merged 1 commit into from
Oct 27, 2017
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
8 changes: 4 additions & 4 deletions components/popover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class Popover extends Component {
return;
}

const { content, popover } = this.nodes;
const { content } = this.nodes;
if ( ! content ) {
return;
}
Expand All @@ -120,8 +120,8 @@ class Popover extends Component {
const firstTabbable = focus.tabbable.find( content )[ 0 ];
if ( firstTabbable ) {
firstTabbable.focus();
} else if ( popover ) {
popover.focus();
} else {
content.focus();
}
}

Expand Down Expand Up @@ -246,13 +246,13 @@ class Popover extends Component {
<div
ref={ this.bindNode( 'popover' ) }
className={ classes }
tabIndex="0"
{ ...contentProps }
onKeyDown={ this.maybeClose }
>
<div
ref={ this.bindNode( 'content' ) }
className="components-popover__content"
tabIndex="-1"
>
{ children }
</div>
Expand Down
4 changes: 4 additions & 0 deletions components/popover/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
width: 300px;
}

&:focus {
box-shadow: $button-focus-style;
}

.components-popover.is-top & {
bottom: 100%;
}
Expand Down
4 changes: 2 additions & 2 deletions components/popover/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ describe( 'Popover', () => {
wrapper = mount( <Popover /> );
wrapper.setProps( { isOpen: true } );

const popover = wrapper.find( '.components-popover' ).getDOMNode();
const content = wrapper.find( '.components-popover__content' ).getDOMNode();

expect( document.activeElement ).toBe( popover );
expect( document.activeElement ).toBe( content );
} );

it( 'should allow focus-on-open behavior to be disabled', () => {
Expand Down
1 change: 0 additions & 1 deletion components/tooltip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ class Tooltip extends Component {
position={ position }
className="components-tooltip"
aria-hidden="true"
tabIndex={ undefined }
>
{ text }
</Popover>,
Expand Down