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

[form validation] keyHeldDown conflicting behavior #3012

Open
alvarolm opened this issue Mar 3, 2024 · 3 comments
Open

[form validation] keyHeldDown conflicting behavior #3012

alvarolm opened this issue Mar 3, 2024 · 3 comments
Labels
state/awaiting-more-info Any issue or pull request which is awaiting more info

Comments

@alvarolm
Copy link
Contributor

alvarolm commented Mar 3, 2024

Bug Report

the use of keyHeldDown together with the "validate form" behavior is not compatible, as (the behavior) when called externally: $(elem).form("validate form") has no key interaction, in fact, it should not consider keyHeldDown when called in this manner.

@alvarolm alvarolm added state/awaiting-investigation Anything which needs more investigation state/awaiting-triage Any issues or pull requests which haven't yet been triaged type/bug Any issue which is a bug or PR which fixes a bug labels Mar 3, 2024
@lubber-de
Copy link
Member

lubber-de commented Mar 4, 2024

keyHeldDown is false by default and only gets set to true whenever a key is actually, well, held down ;) (it gets false again when key is released)
So, when calling the "validate form" behavior (and no key is kept pressed down), this won't affect the form validation. That said i don't see an issue here which we would need to fix.

If i misunderstood or dont understand, please provide a jsfiddle explaining your use case where we can reproduce the need of a change.

@lubber-de lubber-de added state/awaiting-more-info Any issue or pull request which is awaiting more info and removed type/bug Any issue which is a bug or PR which fixes a bug state/awaiting-investigation Anything which needs more investigation state/awaiting-triage Any issues or pull requests which haven't yet been triaged labels Mar 4, 2024
@alvarolm
Copy link
Contributor Author

alvarolm commented Mar 5, 2024

the mechanic to release the "hold" state its not atomic and may be intercepted or canceled by others events

https://github.com/fomantic/Fomantic-UI/blob/develop/src/definitions/behaviors/form.js#L442C49-L442C54

I have resorted to disable keyboardShortcuts and re-implement the desired behavior myself

@lubber-de
Copy link
Member

The mentioned code only applies when the enter key is pressed inside an input to prevent double form submit. In all other cases the keyHeldDown is kept false.
I get your point, but i cannot imagine a use case where the onetime keyup event will not trigger or you call "validate form" in between those special events and use case. I always feel preventing the double submit is more of priority.
In doubt, you could check for a pressed key yourself before calling validate form to double check if the "false" response from the behavior is caused by the keyHeldDown variable. Perhaps this is what you already did now (?)

That said, i actually don't know how/what to change in the FUI core without a proper testcase which illustrates the bug.
So, if possible, please share some jsfiddle :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state/awaiting-more-info Any issue or pull request which is awaiting more info
Projects
None yet
Development

No branches or pull requests

2 participants