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

🐛 [#1121] focus-trap in Header and Search #466

Merged
merged 2 commits into from
Feb 10, 2023

Conversation

jiromaykin
Copy link
Contributor

@jiromaykin jiromaykin commented Feb 10, 2023

Issue: https://taiga.maykinmedia.nl/project/open-inwoner/issue/1121
Problem: propagation (bubbling) of events from the mobile menu into the dialog element that catches focus away from everything else.

Notes for learning:

Ways to inspect the constructor in file "open_inwoner/js/components/abstract/component.js":

constructor(node, initialState = {}) { console.log('Component constructor', node, initialState) [.....]

and

setState(changes) { console.log('setState', changes) [.....]

Ways to inspect the clickEvents in inspector: by using 'matches' in these 5 console-logs in file "open_inwoner/js/components/header/header.js":

bindEvents() { this.node.addEventListener('keyup', this.onKeyUp.bind(this)) this.node.addEventListener('click', (e) => { console.log('click in bindEvents') if ( e.target.matches('.header__button') || e.target.matches('.header__button *') ) { this.setState({ open: !this.state.open }) } }) }

2 & 3.

getButton() { console.log('getButton') return BEM.getChildBEMNode(this.node, BLOCK_HEADER, ELEMENT_BUTTON) } getSubMenu() { console.log('getSubMenu') return BEM.getChildBEMNode(this.node, BLOCK_HEADER, ELEMENT_SUBMENU) }

render(state) { console.log('render', state) document.body.classList.add('body') BEM.toggleModifier(document.body, MODIFIER_OPEN, state.open) BEM.toggleModifier(this.getButton(), MODIFIER_OPEN, state.open) if (matchMedia('(max-width: 767px)').matches) { state.open ? this.getSubMenu().show() : this.getSubMenu().close() } if (state.open) { window.scrollTo({ x: 0, y: 0 }) } }

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@jiromaykin jiromaykin changed the title 🐛 #1121 focus-trap in Header and Search 🐛 [#1121] focus-trap in Header and Search Feb 10, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@codecov-commenter
Copy link

codecov-commenter commented Feb 10, 2023

Codecov Report

Merging #466 (c33434d) into develop (da891a7) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff            @@
##           develop     #466   +/-   ##
========================================
  Coverage    96.43%   96.43%           
========================================
  Files          505      505           
  Lines        18144    18144           
========================================
  Hits         17498    17498           
  Misses         646      646           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jiromaykin jiromaykin marked this pull request as ready for review February 10, 2023 12:54
@jiromaykin jiromaykin requested a review from vaszig February 10, 2023 12:55
Copy link
Contributor

@vaszig vaszig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally and works as expected. Thanks for the notes as well!

@alextreme alextreme merged commit 57898da into develop Feb 10, 2023
@alextreme alextreme deleted the fix/1121-click-trap-from-Search-and-Header branch February 10, 2023 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants