Request toolbar layout after drawable loads
Summary: Fixes #11209 Updating action items in a `ToolbarAndroid`, or more specifically the native `ReactToolbar`, after the initial render presently will not always work as expected - typically manifesting itself as new action items not being displayed at all (under certain circumstances). This seems to be happening because Fresco gets back to us asynchronously and updates the `MenuItem` in a listener. However when a keyboard is displayed the `Toolbar` is in a weird state where updating the `MenuItem` doesn't automatically trigger a layout. The solution is to trigger one manually. This is a bit wacky, so I created a sample project: https://github.com/Benjamin-Dobell/DynamicToolbar `master` demonstrates the problem. Run the project, the toolbar action item is scheduled to update every 2 seconds. It works fine _until_ you give the `TextInput` focus. Once you give it focus the action item disappears and it never recovers (despite on-going renders due to state changes). You can then checkout the `fixed` branch, run `yarn` again, and see that problem is fixed. This branch is using a prebuilt version of React Native with this patch applied. Of course you could (and probably should) also modify `master` to use a version of RN built by the Facebook CI (assuming that's a thing you guys do). Closes https://github.com/facebook/react-native/pull/13876 Differential Revision: D5476858 Pulled By: shergin fbshipit-source-id: 6634d8cb3ee18fd99f7dc4e1eef348accc1c45ad
This commit is contained in:
parent
4de9d64e62
commit
63c2ab3eb1
|
@ -99,6 +99,7 @@ public class ReactToolbar extends Toolbar {
|
|||
@Override
|
||||
protected void setDrawable(Drawable d) {
|
||||
mItem.setIcon(d);
|
||||
ReactToolbar.this.requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue