-
Notifications
You must be signed in to change notification settings - Fork 167
[terra-show-hide] prop to focus on the element added #3838
Conversation
@@ -97,3 +154,4 @@ ShowHide.propTypes = propTypes; | |||
ShowHide.defaultProps = defaultProps; | |||
|
|||
export default injectIntl(ShowHide); | |||
export { ShowHideFocuser }; |
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.
Why is the ShowHide component exporting the ShowHideFocuser component as well?
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.
The ShowHideFocuser provides additional HTML structure around text to allow JAWS walk throw the text with Down Arrow. The user needs to import it along with ShowHide component from the show-hide package. Exporting ShowHideFocuser from the ShowHide.jsx allows to import it as one line with ShowHide like this:
import ShowHide, {ShowHideFocuser} from 'terra-show-hide';
similarly to how we import this:
import React, {useState} from 'react';
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.
Can we have an index.js file and do the exports over there? It feels awkward to use this component to also export a second component.
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.
ref={ref} | ||
tabIndex={focusable ? '-1' : null} | ||
role={focusable ? 'group' : null} | ||
onBlur={() => setFocusable(false)} |
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.
How does the component ever get back to a focusable state? Should this not be allowed?
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.
The only purpose of the focus in this component is to make the assistive technologies announce the text upon opening. For that we need the component to be only focus-able once, and when it looses focus - lose it forever. The only option for the component to become focus-able able again is if user closes and open it back. Does it make sense or I misunderstood the question?
@adoroshk - Upgrading JAWS to the latest version fixed the problem I observed. :) |
afterEach(() => { | ||
jest.restoreAllMocks(); | ||
}); |
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.
restoreAllMocks
only works with spies.
https://jestjs.io/docs/jest-object#jestrestoreallmocks
You should use resetAllMocks
instead. However, that should be done once at the end in the afterAll
function.
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.
fixed here: aa41c4b
import React from 'react'; | ||
import ShowHideFocuser from '../../src/ShowHideFocuser'; | ||
|
||
jest.mock('uuid', () => ({ v4: () => '00000000-0000-0000-0000-000000000000' })); |
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.
let's move this to a beforeAll
function so we are setting and reseting them in the same place.
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.
For some reason I can't make it work with beforeAll
. I looked for examples and everything I was able to find is in the way it is in this implementation. Can we make this change separately, outside of this PR as it is the way it's done terra-wide?
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.
That's fine by me!
@@ -5,6 +5,8 @@ import ThemeContextProvider from 'terra-theme-context/lib/ThemeContextProvider'; | |||
import { mountWithIntl } from 'terra-enzyme-intl'; | |||
import ShowHide from '../../src/ShowHide'; | |||
|
|||
jest.mock('uuid', () => ({ v4: () => '00000000-0000-0000-0000-000000000000' })); |
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.
This mock needs to be reset.
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.
Can you get an example if it's not what's done here: aa41c4b
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.
I'm okay with doing this in a separate PR as suggested here:
https://github.com/cerner/terra-core/pull/3838/files#r1291684878
packages/terra-core-docs/src/terra-dev-site/doc/show-hide/About.1.doc.mdx
Outdated
Show resolved
Hide resolved
packages/terra-core-docs/src/terra-dev-site/doc/show-hide/About.1.doc.mdx
Outdated
Show resolved
Hide resolved
packages/terra-core-docs/src/terra-dev-site/doc/show-hide/About.1.doc.mdx
Outdated
Show resolved
Hide resolved
- Enter key activates the disclosure control and toggles the visibility of the disclosure content. | ||
- Space key activates the disclosure control and toggles the visibility of the disclosure content. |
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.
Is this correct? They both say the same thing.
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.
I guess @mjpalazzo put it that way in purpose. He can answer that better than me.
packages/terra-core-docs/src/terra-dev-site/doc/show-hide/About.1.doc.mdx
Outdated
Show resolved
Hide resolved
packages/terra-core-docs/src/terra-dev-site/doc/show-hide/About.1.doc.mdx
Show resolved
Hide resolved
@@ -97,3 +154,4 @@ ShowHide.propTypes = propTypes; | |||
ShowHide.defaultProps = defaultProps; | |||
|
|||
export default injectIntl(ShowHide); | |||
export { ShowHideFocuser }; |
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.
Can we have an index.js file and do the exports over there? It feels awkward to use this component to also export a second component.
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.
I think this can be just a .js
file as we're not using any .jsx
features.
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.
Oh, that's right, I thought I created a .js
file. Fixing it, will push a commit in a minute.
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.
Here it is: 41cac25
Summary
focusRef
prop was added to pass a ref to the element that should be focused after the full text is shown.<Focuser>
component has been added for cases when user needs to set focus to a text which is not normally focusable.focusRef
provided by customers was preserved for passivity, however it doesn't provide full accessibility.aria-controls
property has been added to the ShowHide button. It contains the id of the ShowHide content<div>
Testing
This change was tested using:
The following specific cases has been tested with assistive technologies:
Reviews
In addition to engineering reviews, this PR needs:
This PR resolves:
UXPLATFORM-9213
UXPLATFORM-9055