Preparing for native typeahead.
Refactored utility funtion used for focusing text input and introduced new function that will be used in typeahead. Common part was extrated to focusAndHandleButtons.
Details
Checked if app builds.
Tested if focusing on reply still works correctly.
focusAndUpdateTextAndSelection tested in future diffs when it's actually used.
Diff Detail
- Repository
- rCOMM Comm
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
native/chat/chat-input-bar.react.js | ||
---|---|---|
648–654 ↗ | (On Diff #21272) | Maybe we should call updateText function? |
669 ↗ | (On Diff #21272) | We can be more specific here, as handle sounds ambiguous. |
675–676 ↗ | (On Diff #21272) | In the previous implementation we were calling these conditionally. Now we're calling them every time focusAndUpdateText is called. Is that intentional? Is it correct to do so? |
Responding to review and introducing hack allowing us for correct selection after typeahead is clicked.
native/chat/chat-input-bar.react.js | ||
---|---|---|
648–654 ↗ | (On Diff #21272) | Right now the context is a bit different and updateText has some code responsible for setting flags in refs, so I think sticking to setting state here is simpler. |
675–676 ↗ | (On Diff #21272) | It allows us to use focusAndHandleButtons and it doesn't create any significant difference in how it looks like. We hide buttons when text input is focused anyway |
Going with sleep(100), waiting for animation flash was unreliable and undeterministic.
native/chat/chat-input-bar.react.js | ||
---|---|---|
729 | This comment needs to be updated – we're no longer waiting for the animation frame to flush |
Fixed comment.
Also changed control selection to false in first setState.
Previously it was set to true, but it didn't affect app behaviour really.
This way it matches comment.
Sorry for that, something hasn't refreshed properly apparently.
We need controlSelection set to true in first setter as that's what Android uses.
Tested on iOS and it doesn't affect behaviour.
native/chat/chat-input-bar.react.js | ||
---|---|---|
734–748 ↗ | (On Diff #21837) | Two things worry me here:
It feels like we should consider using a timeout here and canceling it if appropriate, but I'm not sure. |
native/chat/chat-input-bar.react.js | ||
---|---|---|
734–748 ↗ | (On Diff #21837) |
I went with a timeout you suggested and refactored it all into the separate function as it feels cleaner. |