-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 fix(tooltip,modal): interaction globale et focus iOS [DS-3460,DS-33…
…95] (#691) - Correctif à la pression de la touche Escape sur la modale : si l'élément actif (focus) est un élément de formulaire ou un média, la modale n'est pas refermée pas pour permettre l'interaction native de l'élément actif - Correctif iOS de la prise de focus au clic - Fermeture des tooltips dés au clic sur n'importe quel endroit - Fermeture des tooltip à la pression sur la touche escape, où que soit le focus
- Loading branch information
Showing
9 changed files
with
133 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,36 @@ | ||
export const KeyCodes = { | ||
TAB: 9, | ||
ESCAPE: 27, | ||
END: 35, | ||
HOME: 36, | ||
LEFT: 37, | ||
UP: 38, | ||
RIGHT: 39, | ||
DOWN: 40 | ||
TAB: { | ||
id: 'tab', | ||
value: 9 | ||
}, | ||
ESCAPE: { | ||
id: 'escape', | ||
value: 27 | ||
}, | ||
END: { | ||
id: 'end', | ||
value: 35 | ||
}, | ||
HOME: { | ||
id: 'home', | ||
value: 36 | ||
}, | ||
LEFT: { | ||
id: 'left', | ||
value: 37 | ||
}, | ||
UP: { | ||
id: 'up', | ||
value: 38 | ||
}, | ||
RIGHT: { | ||
id: 'right', | ||
value: 39 | ||
}, | ||
DOWN: { | ||
id: 'down', | ||
value: 40 | ||
} | ||
}; | ||
|
||
export const getKeyCode = (keyCode) => Object.values(KeyCodes).filter(entry => entry.value === keyCode)[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import ns from '../../utilities/namespace.js'; | ||
|
||
export const RootEmission = { | ||
CLICK: ns.emission('root', 'click'), | ||
KEYDOWN: ns.emission('root', 'keydown'), | ||
KEYUP: ns.emission('root', 'keyup') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const RootSelector = { | ||
ROOT: ':root' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,33 @@ | ||
import { Element } from './element.js'; | ||
import ns from '../../utilities/namespace.js'; | ||
import { RootEmission } from './root-emission'; | ||
import { getKeyCode } from '../register/key-codes'; | ||
|
||
class Root extends Element { | ||
constructor () { | ||
super(document.documentElement, 'root'); | ||
this.node.setAttribute(ns.attr('js'), true); | ||
this.listen(); | ||
} | ||
|
||
listen () { | ||
// TODO v2 => listener au niveau des éléments qui redistribuent aux instances. | ||
document.documentElement.addEventListener('click', this.click.bind(this), { capture: true }); | ||
document.documentElement.addEventListener('keydown', this.keydown.bind(this), { capture: true }); | ||
document.documentElement.addEventListener('keyup', this.keyup.bind(this), { capture: true }); | ||
} | ||
|
||
click (e) { | ||
this.emit(RootEmission.CLICK, e.target); | ||
} | ||
} | ||
|
||
const RootSelector = { | ||
ROOT: ':root' | ||
}; | ||
keydown (e) { | ||
this.emit(RootEmission.KEYDOWN, getKeyCode(e.keyCode)); | ||
} | ||
|
||
keyup (e) { | ||
this.emit(RootEmission.KEYUP, getKeyCode(e.keyCode)); | ||
} | ||
} | ||
|
||
export { Root, RootSelector }; | ||
export { Root }; |