-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[HOLD for payment 2022-05-20][$1000] Input is lost upon pressing ⌘K to open the Search View #6069
Comments
Triggered auto assignment to @laurenreidexpensify ( |
I have posted a technique here #4822 (comment). Let me know how does that sound? |
@parasharrajat would you be willing to make a formal proposal here for posterity? |
@Luke9389 I am experimenting with another approach. UpdateOK, I have a fascinating idea of how can we do this without losing the animation. and It works.
This how it can be done // captures keys on keypress event.
function buffer(captureOnInputs = false) {
if (keyBufferCallback) {
return;
}
keyBufferCallback = (evt) => {
if (!captureOnInputs
&& evt.target.nodeName === 'INPUT'
&& evt.target.nodeName === 'TEXTAREA'
&& evt.target.contentEditable === 'true') {
return;
}
let chrCode = 0;
if (evt.charCode != null) {
chrCode = evt.charCode;
} else if (evt.which != null) {
chrCode = evt.which;
} else if (evt.keyCode != null) {
chrCode = evt.keyCode;
}
if (chrCode !== 0) {
keyBuffer += String.fromCharCode(chrCode);
}
};
document.addEventListener('keypress', keyBufferCallback, {capture: true});
}
// returns the value stored in bufffer and unsubscribe from keypress.
function consumeBuffer() {
const value = keyBuffer;
document.removeEventListener('keypress', keyBufferCallback, {capture: true});
keyBuffer = '';
keyBufferCallback = null;
return value;
} Now when we navigate to searchPage. we start the buffer via navigateToSearchPage() {
Navigation.navigate(ROUTES.SEARCH);
KeyboardShortcut.buffer(false);
} and consume it in <ScreenWrapper
onTransitionEnd={() => {
const searchValue = KeyboardShortcut.consumeBuffer();
this.setState({didScreenTransitionEnd: true, searchValue}, this.updateOptions);
}}
> |
This is a really cool idea. I'd be interested to see how many places in our code could use this type of behavior. We call Does this direction make sense for you? Essentially I'm wanting to implement this behavior in a manner that can be applied elsewhere. The assumption for me is "more generalizable" = "better". I'm going to loop in @marcaaron here to see what his thoughts are. |
I think I like this workaround better. The code feels a bit complex to me for solving an edge case. I've never had a problem with typing into this search box. |
Yup, this is an edge case but Matt is really finding this problematic. and that's why I invested time to find a solution. I would say yes. We can add this into |
ProposalAutofocus on TextInput breaks the animation because the browser scrolls to the TextInput! Modify this card style.
We'll conditionally render the search results based on Verification here - https://jsfiddle.net/e01tjwvq/1/ This has 2 inputs (one is fixed, one is absolute) Click run. Result --> Input with (Increase height of the viewport to verify that both inputs exist) |
@Luke9389 can you review Rushat's proposal above please? |
Thanks for the bump @mallenexpensify Ok @parasharrajat, lets do this thing! Go ahead an make a PR. |
omg, not again 😂 |
ETA for PR: 1 day. |
It wasn't me this time @rushatgabhane !!! |
@rushatgabhane is working on the PR |
Actually, PR is awaiting a review |
Looks like @Luke9389 needs to review the PR #8535 (comment) |
PR is on staging |
Go away melvin 😄 |
Been on staging 16 days which seems like a lot ¯_(ツ)_/¯h |
PR is on production, will pay 5/20 if no regressions, updated title |
@rushatgabhane , you're due $1000 for this, right? If so, can you accept the offer I just sent? |
@mallenexpensify yes, accepted! |
Paid @rushatgabhane $1000 for fixing the issue. |
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results. If a production regression has occurred a Root Cause Analysis is required. Please follow the instructions here. If a regression has occurred and you are the assigned CM follow the instructions here. If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future. |
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel! https://www.upwork.com/jobs/~01a9fa1b364d799b4c
If you start typing right after pressing ⌘K, some of your inputs might be lost as a result of the transition time for bringing up the search view. In a recent PR, @Santhosh-Sellavel attempted to shorten the animation time, but the problem persisted.
Action Performed:
Expected Result:
All of the text you type should be captured.
Actual Result:
Only the text that you type after the Search View has rendered gets captured.
Workaround:
Don't type so fast 😄
Platform:
Where is this issue occurring?
Version Number:
Reproducible in staging?:
Reproducible in production?:
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Expensify/Expensify Issue URL:
Issue reported by:
Slack conversation:
View all open jobs on GitHub
The text was updated successfully, but these errors were encountered: