Comments (5)
That makes sense. Just remove that re focus line...
from primefaces.
Thank you it is working.
from primefaces.
Try this version:
pf-11551.zip
Run mvn clean jetty:run
and navigate to http://localhost:8080/primefaces-test/
if (PrimeFaces.widget.DefaultCommand) {
PrimeFaces.widget.DefaultCommand.prototype.init = function(cfg) {
PrimeFaces.widget.BaseWidget.prototype.init.call(this, cfg);
// Cache frequently used elements and values
this.jqTarget = $(PrimeFaces.escapeClientId(this.cfg.target));
this.scope = this.cfg.scope ? $(PrimeFaces.escapeClientId(this.cfg.scope)) : null;
var $this = this;
var scopeEnterKey = 'keydown.' + this.id;
// Support container elements such as splitButton
if (this.jqTarget.is(':not(:button):not(:input):not(a)')) {
this.jqTarget = this.jqTarget.find('button,a').filter(':visible').first();
}
// Attach keypress listener to parent form
var closestForm = this.jqTarget.closest('form');
closestForm.off(scopeEnterKey).on(scopeEnterKey, {
scopeEnter: false
}, function(e, data) {
data = data || e.data;
if (($this.scope && data.scopeEnter && data.scopeDefaultCommandId === $this.id) ||
(!$this.scope && !data.scopeEnter && (e.key === 'Enter'))) {
var eventTarget = $(e.target);
// Do not proceed if target is a textarea, button, link, or TextEditor
if (eventTarget.is('textarea,button,input[type="submit"],a,.ql-editor')) {
return true;
}
if (!$this.jqTarget.is(':disabled, .ui-state-disabled')) {
// focus default command button and click it
$this.jqTarget.trigger('focus').trigger(PrimeFaces.csp.clickEvent($this.jqTarget));
// re-focus the original input that pressed ENTER
eventTarget.trigger('focus');
}
e.preventDefault();
e.stopImmediatePropagation();
}
});
// Add keydown listener to scope if available
if (this.scope) {
this.scope.off(scopeEnterKey).on(scopeEnterKey, function(e) {
if (e.key === 'Enter') {
closestForm.trigger(e, {
scopeEnter: true,
scopeDefaultCommandId: $this.id
});
e.stopPropagation();
}
});
}
}
}
from primefaces.
@melloware I tried it. I think it is a nice idea to return the focus, do you think this can result in errors if the commandButton updates the content or forwards/redirects to another page, so that the eventTarget is not available any more?
Nevertheless, returning the focus results in a loop where, the
- 1 request is from the inputText
- 2 request is from the commandButton
- 3 ... n requests are from the inputText
The line which is returning the focus and causing the loop
from primefaces.
Awesome I updated my PR to remove that line as well.
from primefaces.
Related Issues (20)
- DatePicker's time falls into an infinitive loop HOT 18
- TabView/AccordionPanel: Introduce TabEvent#index HOT 2
- DataTable: Frozen Col with virtualscroll does not scroll any longer since 13.0.7 HOT 1
- DataTable: checkbox unselects items from other pages HOT 1
- DefaultCommand: dataTable with filterEvent="keydown" triggers defaultCommand on enter HOT 7
- Provide a JS util to overwrite a local specific setting like firstDayOfWeek for all locales on the current view HOT 2
- AutoComplete: Enable ctrl+click/shift+click when using multiple='true' HOT 1
- UITabPanel: replace with UIData HOT 3
- Captcha: Support hCaptcha
- SelectBooleanCheckbox: in Firefox, NVDA just reads "blank" when checkbox is focused with tab HOT 9
- Dialog: Dialog extends beyond viewport after resizing due to AJAX update HOT 30
- Core: getResourceScriptURI returning incorrect URI
- SelectOneRadio: Exponential AJAX calls when using custom layout HOT 2
- DataScroller: facet loader is not rendered, because the rowCount is badly set HOT 1
- InputMask: Problem escaping characters and validateMask HOT 1
- CSP: create a subclass of FacesException? HOT 3
- Sticky: MenuBar sticky should always show on top HOT 1
- Timeline: some items are hidden in some usecases HOT 2
- DataTable: selection issue with overlayPanel and dialog HOT 8
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.