Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

fix(Popup): Adding toggle functionality if trigger element is not button #758

Merged
merged 16 commits into from
Jan 31, 2019

Conversation

kolaps33
Copy link
Collaborator

@kolaps33 kolaps33 commented Jan 22, 2019

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 >

  • then with keyboard "Enter" should open popup and "ESC" close
  • then with keyboard "Enter" should open popup and "Enter" close (toggle)

Copy link
Member

@levithomason levithomason left a 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.

Copy link
Collaborator

@silviuaavram silviuaavram left a 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.

@mnajdova
Copy link
Contributor

This has regressions on the popups that have on="hover" or on="focus". In this cases, the enter/space should always open the popup not open and close it. We should add the toggling behavior only if we have click as a combination in the value of the on prop.

@jurokapsiar
Copy link
Contributor

We should add the toggling behavior only if we have click as a combination in the value of the on prop.

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')
Copy link
Contributor

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')
Copy link
Contributor

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

yarn.lock Outdated Show resolved Hide resolved
@mnajdova mnajdova dismissed levithomason’s stale review January 31, 2019 14:20

The requested changes were implemented.

@mnajdova mnajdova merged commit 0a00d34 into master Jan 31, 2019
@layershifter layershifter deleted the mituron-toggle-popup branch January 31, 2019 14:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants