mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Merge pull request #33534 from overleaf/em-fix-autocomplete-32913
Fix autocomplete dropdown closing on blur and input re-click GitOrigin-RevId: 82f45f0f1ae9e2b3846906d962a3f16e5b2963e4
This commit is contained in:
@@ -60,6 +60,7 @@ function render(props: RenderProps) {
|
||||
useFuzzySearch={props.useFuzzySearch}
|
||||
expandUp={props.expandUp}
|
||||
onClose={props.onClose}
|
||||
isOpen={props.isOpen}
|
||||
/>
|
||||
<button type="submit">submit</button>
|
||||
</form>
|
||||
@@ -551,6 +552,35 @@ describe('<OLAutocomplete />', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('controlled isOpen prop', function () {
|
||||
it('keeps dropdown open when input is blurred', function () {
|
||||
render({ items: testItems, isOpen: true })
|
||||
cy.findByRole('combobox').click()
|
||||
cy.get('.dropdown-menu.show').should('exist')
|
||||
|
||||
cy.findByRole('combobox').blur()
|
||||
cy.get('.dropdown-menu.show').should('exist')
|
||||
})
|
||||
|
||||
it('keeps dropdown open when input is clicked while already open', function () {
|
||||
render({ items: testItems, isOpen: true })
|
||||
cy.findByRole('combobox').click()
|
||||
cy.get('.dropdown-menu.show').should('exist')
|
||||
|
||||
cy.findByRole('combobox').click()
|
||||
cy.get('.dropdown-menu.show').should('exist')
|
||||
})
|
||||
|
||||
it('calls onClose when Escape is pressed', function () {
|
||||
const closeHandler = cy.stub().as('closeHandler')
|
||||
render({ items: testItems, isOpen: true, onClose: closeHandler })
|
||||
|
||||
cy.findByRole('combobox').type('{esc}')
|
||||
|
||||
cy.get('@closeHandler').should('have.been.calledOnce')
|
||||
})
|
||||
})
|
||||
|
||||
describe('expandUp prop', function () {
|
||||
it('renders search bar before results list when expandUp is false', function () {
|
||||
render({ items: testItems, expandUp: false })
|
||||
|
||||
Reference in New Issue
Block a user