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

Focus on inputText with material css. #132

Open
MSet7 opened this issue Sep 26, 2018 · 5 comments
Open

Focus on inputText with material css. #132

MSet7 opened this issue Sep 26, 2018 · 5 comments
Labels

Comments

@MSet7
Copy link

MSet7 commented Sep 26, 2018

Issue Overview

How to set a focus to a p:inputText with material css.

Current Behaviour

Cursor not in inputText
2018-09-26_16-04-40

Expected Behaviour

cursor in inputText when the page is loaded.

How to reproduce

2018-09-26_16-12-03

Just add <p:focus for="email"/> to login starter page (material).

Additional Information
  • AdminFaces version: 1.0.0-RC18
  • PrimeFaces version: 6.2
  • JSF implementation: 2.3
@rmpestano rmpestano added the bug label Sep 26, 2018
@rmpestano
Copy link
Contributor

rmpestano commented Sep 26, 2018

Hi, unfortunately the material inputs are processed on page load (see here) hence the initial focus gets lost.

The only workaround I can think now is to set the focus after an initial delay:

$(document).ready(function () {
                setTimeout(function () {
                    $('#email').focus();
                }, 250);
            });

$(document).on("pfAjaxComplete", function () {
                setTimeout(function () {
                    $('#email').focus();
                }, 250);
            });

@lfpaz
Copy link

lfpaz commented Mar 7, 2022

I know this issue is old, but i used this workaround in a external JS file:

var oldAdminMaterial = adminMaterial;

adminMaterial = function () {
    var x = document.activeElement.id;
    var xValue = document.activeElement.value;
    oldAdminMaterial();
    if (x) {
        document.getElementById(x).value = xValue;
        document.getElementById(x).focus();
    }
} 

with this, the <p:focus/> work in any situation i ever have tested. The value copy is needed for pages when <p:autocomplete/> is the first component in page.

@MSet7 @rmpestano

@rmpestano
Copy link
Contributor

Hey @lfpaz, can you open a PR?

I'm trying to get the project back on track by updating to the latest PrimeFaces and would be nice to incorporate this fix.

Thank you in advance!

@lfpaz
Copy link

lfpaz commented Mar 29, 2022

@rmpestano i will open in next days. I'm busy now with the preparations of birth of my son.

@rmpestano
Copy link
Contributor

Thanks @lfpaz! No rush as I'm also quite busy here.

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants