-
Notifications
You must be signed in to change notification settings - Fork 55
fix(Popup): Adding toggle functionality if trigger element is not button #758
Conversation
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 get a test added that shows this works. Ensure to make assertions only on what the end user has access to. That means avoid making assertions that the state changed, and prefer things like checking if the popup is actually open on the page.
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.
Split the test into 2 distinct ones. But the thing you actually test is ok.
This has regressions on the popups that have |
agree for click. for other combinations we should do the same what click event does - open the popup if not already open. |
@@ -36,6 +38,57 @@ describe('Popup', () => { | |||
}: PositionTestInput & { rtl?: never }) => | |||
testPopupPosition({ align, position, expectedPlacement, rtl: true }) | |||
|
|||
const getPopupContent = (popup: ReactWrapper) => { | |||
return popup.find('.ui-popup__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.
lets use interpolated class names instead of hardcoded strings:
return popup.find(`${Popup.Content.className}`)
@@ -131,4 +184,11 @@ describe('Popup', () => { | |||
expect(spy.mock.calls[0][1]).toMatchObject({ open: true }) | |||
}) | |||
}) | |||
|
|||
describe('open/close popup by keyboard', () => { | |||
togglePopupTest('enter', keyboardKey.Enter, 'click') |
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.
nit: lets rename it in a way togglePopupTest
-> testPopupToggleOn
, this will make test's code more readable
The requested changes were implemented.
Currently if the trigger element for the popup is not button, then popup is not open by Enter/Space key.
Specification by @jurokapsiar regarding Mouse vs Keyboard action.
Mouse hover > then with keyboard "Enter" should open popup and "ESC" close
Focus > then with keyboard "Focus" should open popup and "ESC" close
Click >