Comments (10)
nice ...
from primefaces.
@EugenFischer when you say "long click" do you mean on a mobile browser?
from primefaces.
I just tried your scenario in Windows 11 Chrome and its not happening for me?
from primefaces.
OK nevermind it happens on the VERY FIRST click after loading the page but stops happening after that.
from primefaces.
Bug is right here....
this.jq.off('focus.pickList blur.pickList keydown.pickList', listSelector).on('focus.pickList', listSelector, null, function(e) {
var list = $(this),
activeItem = $this.focusedItem||list.children('.ui-state-highlight:visible:first');
from primefaces.
MonkeyPatch:
if (PrimeFaces.widget.PickList) {
PrimeFaces.widget.PickList.prototype.bindItemEvents = function() {
var $this = this;
this.items.on('mouseover.pickList', function(e) {
$(this).addClass('ui-state-hover');
})
.on('mouseout.pickList', function(e) {
$(this).removeClass('ui-state-hover');
})
.on('click.pickList', function(e) {
//stop propagation
if ($this.checkboxClick || $this.dragging) {
$this.checkboxClick = false;
return;
}
var item = $(this),
parentList = item.parent(),
metaKey = (e.metaKey || e.ctrlKey);
if (!e.shiftKey) {
if (!metaKey) {
$this.unselectAll();
}
if (metaKey && item.hasClass('ui-state-highlight')) {
$this.unselectItem(item, true);
} else {
$this.selectItem(item, true);
$this.cursorItem = item;
}
} else {
$this.unselectAll();
if ($this.cursorItem && ($this.cursorItem.parent().is(item.parent()))) {
var currentItemIndex = item.index(),
cursorItemIndex = $this.cursorItem.index(),
startIndex = (currentItemIndex > cursorItemIndex) ? cursorItemIndex : currentItemIndex,
endIndex = (currentItemIndex > cursorItemIndex) ? (currentItemIndex + 1) : (cursorItemIndex + 1);
for (var i = startIndex; i < endIndex; i++) {
var it = parentList.children('li.ui-picklist-item').eq(i);
if (it.is(':visible')) {
if (i === (endIndex - 1))
$this.selectItem(it, true);
else
$this.selectItem(it);
}
}
} else {
$this.selectItem(item, true);
$this.cursorItem = item;
}
}
/* For keyboard navigation */
$this.removeOutline();
$this.focusedItem = item;
parentList.trigger('focus.pickList');
});
if (this.cfg.transferOnDblclick) {
this.items.on('dblclick.pickList', function() {
var item = $(this);
if ($(this).parent().hasClass('ui-picklist-source')) {
$this.transfer(item, $this.sourceList, $this.targetList, 'dblclick');
} else {
$this.transfer(item, $this.targetList, $this.sourceList, 'dblclick');
}
/* For keyboard navigation */
$this.removeOutline();
$this.focusedItem = null;
PrimeFaces.clearSelection();
});
}
if (this.cfg.showCheckbox) {
this.checkboxes.off().on('mouseenter.pickList', function(e) {
$(this).addClass('ui-state-hover');
})
.on('mouseleave.pickList', function(e) {
$(this).removeClass('ui-state-hover');
})
.on('mousedown.pickList', function(e) {
var item = $(this).closest('li.ui-picklist-item');
$this.focusedItem = item;
})
.on('click.pickList', function(e) {
$this.checkboxClick = true;
var item = $(this).closest('li.ui-picklist-item');
if ($this.cfg.transferOnCheckboxClick) {
if (item.parent().hasClass('ui-picklist-source')) {
$this.transfer(item, $this.sourceList, $this.targetList, 'checkbox', function() {
$this.unselectItem(item);
});
} else {
$this.transfer(item, $this.targetList, $this.sourceList, 'checkbox', function() {
$this.unselectItem(item);
});
}
} else {
if (item.hasClass('ui-state-highlight')) {
$this.unselectItem(item, true);
} else {
$this.selectItem(item, true);
}
$this.focusedItem = item;
}
});
}
}
}
from primefaces.
awesome
from primefaces.
Thanks a lot.
Even if there is no direct usecase for,
but maybe you have an idea why the scrolling also happens or right-clicking on an element.
from primefaces.
oh let me check the right click i was more worried about that long left click.
from primefaces.
Try this
if (PrimeFaces.widget.PickList) {
PrimeFaces.widget.PickList.prototype.bindItemEvents = function() {
var $this = this;
this.items.on('mouseover.pickList', function(e) {
$(this).addClass('ui-state-hover');
})
.on('mouseout.pickList', function(e) {
$(this).removeClass('ui-state-hover');
})
.on('mousedown.pickList', function(e) {
var item = $(this).closest('li.ui-picklist-item');
$this.focusedItem = item;
})
.on('click.pickList', function(e) {
//stop propagation
if ($this.checkboxClick || $this.dragging) {
$this.checkboxClick = false;
return;
}
var item = $(this),
parentList = item.parent(),
metaKey = (e.metaKey || e.ctrlKey);
if (!e.shiftKey) {
if (!metaKey) {
$this.unselectAll();
}
if (metaKey && item.hasClass('ui-state-highlight')) {
$this.unselectItem(item, true);
} else {
$this.selectItem(item, true);
$this.cursorItem = item;
}
} else {
$this.unselectAll();
if ($this.cursorItem && ($this.cursorItem.parent().is(item.parent()))) {
var currentItemIndex = item.index(),
cursorItemIndex = $this.cursorItem.index(),
startIndex = (currentItemIndex > cursorItemIndex) ? cursorItemIndex : currentItemIndex,
endIndex = (currentItemIndex > cursorItemIndex) ? (currentItemIndex + 1) : (cursorItemIndex + 1);
for (var i = startIndex; i < endIndex; i++) {
var it = parentList.children('li.ui-picklist-item').eq(i);
if (it.is(':visible')) {
if (i === (endIndex - 1))
$this.selectItem(it, true);
else
$this.selectItem(it);
}
}
} else {
$this.selectItem(item, true);
$this.cursorItem = item;
}
}
/* For keyboard navigation */
$this.removeOutline();
$this.focusedItem = item;
parentList.trigger('focus.pickList');
});
if (this.cfg.transferOnDblclick) {
this.items.on('dblclick.pickList', function() {
var item = $(this);
if ($(this).parent().hasClass('ui-picklist-source')) {
$this.transfer(item, $this.sourceList, $this.targetList, 'dblclick');
} else {
$this.transfer(item, $this.targetList, $this.sourceList, 'dblclick');
}
/* For keyboard navigation */
$this.removeOutline();
$this.focusedItem = null;
PrimeFaces.clearSelection();
});
}
if (this.cfg.showCheckbox) {
this.checkboxes.off().on('mouseenter.pickList', function(e) {
$(this).addClass('ui-state-hover');
})
.on('mouseleave.pickList', function(e) {
$(this).removeClass('ui-state-hover');
})
.on('mousedown.pickList', function(e) {
var item = $(this).closest('li.ui-picklist-item');
$this.focusedItem = item;
})
.on('click.pickList', function(e) {
$this.checkboxClick = true;
var item = $(this).closest('li.ui-picklist-item');
if ($this.cfg.transferOnCheckboxClick) {
if (item.parent().hasClass('ui-picklist-source')) {
$this.transfer(item, $this.sourceList, $this.targetList, 'checkbox', function() {
$this.unselectItem(item);
});
} else {
$this.transfer(item, $this.targetList, $this.sourceList, 'checkbox', function() {
$this.unselectItem(item);
});
}
} else {
if (item.hasClass('ui-state-highlight')) {
$this.unselectItem(item, true);
} else {
$this.selectItem(item, true);
}
$this.focusedItem = item;
}
});
}
}
}
from primefaces.
Related Issues (20)
- DefaultCommand: Not working for button outside (but linked to) form HOT 2
- ToggleSwitch included in components.js HOT 1
- Dialog: focus is not set from CommandLink
- AutoComplete: Custom HTML content is destoyed by query matches highlighting HOT 3
- AjaxStatus: Not returning to default when located outside the ajax partial submit update scope HOT 6
- jQuery UI 1.13.3
- Spinner: serverside input validation HOT 1
- AutoComplete no empty message if forceSelection is false or introduce a new attribute showEmptyMessage HOT 7
- Dialog: Position is being reset on scroll HOT 8
- SONAR: enable quality checks on JS/CSS files
- Menu: Provide screen reader compliant navigation for accessibility. HOT 2
- SelectCheckboxMenu: Update accessibility HOT 8
- Core: Do not shade BoundedInputStream
- Dialog: Focus from input lost in very short time after dialog opened HOT 6
- SONAR: Fix JS issues HOT 2
- SONAR: Fix CSS issues HOT 2
- Captcha: command button not working with p:captcha HOT 5
- JDK8: `org.json` dependency causes java version mistatch HOT 4
- SubTable: still alive even after been announced deprecated in 10.0.0 HOT 8
- Integration-tests: move to JakartaEE (10) HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from primefaces.