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

Sirius JS: Allows to suppress enter listener when shift is pressed #1266

Merged
merged 2 commits into from
Aug 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/main/resources/default/assets/common/core.js.pasta
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,13 @@ sirius.findParentOfType = function (_node, type) {
*
* @param _node the node to attach the listener on
* @param listener the listener to attach
* @param [suppressOnShift] if true, the listener is only invoked if shift is not simultaneously pressed
*/
sirius.addEnterListener = function (_node, listener) {
sirius.addEnterListener = function (_node, listener, suppressOnShift) {
_node.addEventListener('keydown', function (event) {
if (suppressOnShift && event.shiftKey) {
return;
}
if (event.key === 'Enter') {
event.preventDefault();
listener(event);
Expand Down Expand Up @@ -246,7 +250,7 @@ sirius.throttle = function (fn, threshold) {
/**@
* Adds an event listener that triggers exactly once per element when it becomes visible or is about to become visible.
* <p>
* The event will trigger once an element comes within a certain distance to the viewport. By default the vertical and
* The event will trigger once an element comes within a certain distance to the viewport. By default, the vertical and
* horizontal distances are equal to the element's height and width respectively. This distance can be increased by
* specifying a value greater than 1 as the distanceFactor.
*
Expand Down