-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Blur Magic Code input when click outside #24012
Conversation
@Santhosh-Sellavel Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Workswell, so far so good. But will continue testing this further |
Resolve conflicts, thanks! |
Tests well mostly one issue I spotted here, tab/shift+tab does not focus on the next/previous code input like we have arrow navigation Screen.Recording.2023-08-08.at.12.29.58.AM.movcc: @dangrous |
What should we do here @dangrous? |
Oh hm, because it's one big input, yeah. Can we add a listener for the tab key if the focus is in the component? |
I tested it and it seems like it's kinda hard to change behaviour of |
Not sure about this though. What we do here, is a kind of magic trick creating impression that there a six input to get each value of the code. But behind the scenes, there is a different story right, can we call it a hack?
Yes, It should be like how it was before.
No,For each number, we have a separate field for a customer POV, so the tab/shift-tab should focus on the next/prev field, that's the basic expectation
We don't need to compare arrow/tab. Arrow is an addon to navigate through the field, the tab is an accessibility feature cc: @dangrous thoughts? |
Santhosh-Sellavel I see it differently. From my perspective customer is entering one value - namely magic code. Hence, navigating between characters within one field is based on arrows. Tab press in my mind switches to next input, which should logically correspond to next inputed value. Here - it should go from Magic Code to whatever is next. The way I look at it is that Magic Code Input in my mind is in fact ONE input but with styling that underlines each character separately. Even from code perspective it is actually one input, so I believe it should be treated as such. If we look at it as a reusable component, it could theoretically be used as part of some screen that contains more than one input - say for entering postal code or phone number somewhere. Wouldn't you expect then Tab to switch you to next field of form, rather than next character of input? Having said all that, I think that IDEAL solution would be to have it configurable with some prop. But given it might be hard and not really used ever, I'd stick to what we've got. |
Yeah that's an interesting point. Because tab is primarily used for accessibility, and from an accessibility perspective, for example a blind user would actively want it to act as one input, vs. 6. I think you've swayed me, @mczernek! I don't think we have to worry about that issue. |
Cool, then. If it haunts back us let's handle it along with accessibility milestones. As I see accessibility is not a priority ATM. |
That works for me! |
Moved here |
Bug: Backspace not working on mWeb Safari after unfocusing and focusing the input. Screen.Recording.2023-08-12.at.2.17.57.AM.mov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump @wojtus7 |
I'm afraid we can't do much about placement of the paste button without some hacky solution 😞 But I am working rn to fix keyboard behaviour and make it uniform on web and native |
@dangrous while trying to disable focus after error I found this code and comment: I can remove it but just want to make sure we don't regress pretty fresh fix here, and maybe we should just fix highlight of the selected input? |
Hey @wotjus try pulling main - I don't see that comment any more (so maybe it's okay for us to unfocus)
That's fine, that was a relatively minor issue. As long as it still pops up wherever you click (which it seems like it does), fine by me. |
Now with refocus logic removed, all platforms behave the same: (No keyboard, all digits red - user has to touch/click some space to edit it) Nagranie.z.ekranu.2023-09-25.o.20.25.05.mov@dangrous can you confirm this is what we wanted? |
Yes this is what we wanted. |
All good, tests well for me! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, All yours @dangrous!
Nice! Yep that's what I think expected behavior should be. Will look through this in a moment, and we can merge! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great! One tiny change, then ready to merge!
Co-authored-by: Daniel Gale-Rosen <5487802+dangrous@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pushing this over the line!
Congrats, that’s your 5th PR merged! 🎉 Do you know about the ContributorPlus role? It’s an opportunity to earn more in the Expensify Open Source community. Keep up the great work - thanks! |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/dangrous in version: 1.3.75-0 🚀
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.3.75-12 🚀
|
🚀 Deployed to staging by https://github.com/dangrous in version: 1.3.76-0 🚀
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.3.76-6 🚀
|
@@ -91,22 +95,40 @@ const composeToString = (value) => _.map(value, (v) => (v === undefined || v === | |||
const getInputPlaceholderSlots = (length) => Array.from(Array(length).keys()); | |||
|
|||
function MagicCodeInput(props) { | |||
const inputRefs = useRef([]); | |||
const [input, setInput] = useState(''); | |||
const inputRefs = useRef(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we change from array to single inputRefs here, we forgot to update those lines as well
App/src/components/MagicCodeInput.tsx
Lines 280 to 281 in 4a3f2da
const formElement = inputRefs.current as HTMLFormElement | null; | |
(formElement?.[indexToFocus] as HTMLInputElement)?.focus(); |
It caused a bug here #50315. More details: #50315 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh huh, thanks!
Details
In order to make blur possible I needed to refactor the magic component. Instead of 6 separate text inputs there is only one wrapped inside TapGestureHandler that determine which number should be inputed. This resulted is some code that is simpler, taps are handled by gesture handler and right-click/context menu/context is handled by native text input. but at the same time created small issue that paste button shows only on the beginning of the input.
Fixed Issues
$ #18244
PROPOSAL: #18244 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
bez.nazwy.mov
Mobile Web - Chrome
Screenrecorder-2023-08-01-17-22-47-275.mp4
Mobile Web - Safari
Nagranie.z.ekranu.2023-08-1.o.14.42.25.mov
Desktop
bez.nazwy.mov
iOS
Nagranie.z.ekranu.2023-08-1.o.14.44.35.mov
Android
Nagranie.z.ekranu.2023-08-1.o.14.41.23.mov