Skip to content

Migrate setNativeProps to state in OptionsSelector #11053

Closed

Description

@luacmartins

Coming from #8503, enabling Fabric requires us to migrate off setNativeProps. We should move usages of setNativeProps to state in OptionsSelector

Activity

  1. melvin-bot commented on Sep 23, 2022

    @melvin-bot

    ⚠️ Looks like this issue was linked to a Deploy Blocker here

    If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

    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.

  2. rushatgabhane commented on Sep 26, 2022

    @rushatgabhane
    Member

    We had to revert the migration because a regression here - #11239

    This is the only related change that caused it. And it is expected because we're using controlled selection (async setState).
    @luacmartins I don't think there is much we can do to fix it.

    selection={this.state.selection}
    onSelectionChange={e => this.setState({selection: e.nativeEvent.selection})}

  3. rushatgabhane commented on Sep 26, 2022

    @rushatgabhane
    Member

    Exploring a fix

  4. melvin-bot commented on Sep 27, 2022

    @melvin-bot

    ⚠️ Looks like this issue was linked to a possible regression on PRODUCTION here

    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.

  5. melvin-bot commented on Sep 27, 2022

    @melvin-bot

    ⚠️ Looks like this issue was linked to a possible regression on PRODUCTION here

    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.

  6. rushatgabhane commented on Sep 30, 2022

    @rushatgabhane
    Member

    no updates here. couldn't make time

  7. rushatgabhane commented on Oct 6, 2022

    @rushatgabhane
    Member

    Update: I have no idea what was causing the regression and how to fix it #11239

    Thoughts: The following reasons make me think that it's a purely performance related issue. To fix it, we'll have to make OptionsSelector more performant.

    1. The ONLY code that's dealing with selection when typing text is -

    selection={this.state.selection}
    onSelectionChange={e => this.setState({selection: e.nativeEvent.selection})}

    ^ It's the most basic form of controlled selection.

    1. This issue is noticeable only on mobile devices.
    2. OptionsSelector is an expensive component.
  8. rushatgabhane commented on Oct 6, 2022

    @rushatgabhane
    Member

    @luacmartins @roryabraham I'm curious about your thoughts on #11053 (comment)

    How should we proceed?

    1. Get rid of controlled selection completely. And re-add it after Fabric has been enabled.
      CONS:
      a) we'll lose the feature that selects the search text when a option is selected - feature demo here
      b) regression not being present on fabric is an assumption and we could be wrong.

    2. Assign this issue to someone else

    3. ???

  9. roryabraham commented on Oct 6, 2022

    @roryabraham
    Contributor

    Can't promise anything, but I'm going try looking into this a bit

  10. self-assigned this
    on Oct 6, 2022
  11. luacmartins commented on Oct 6, 2022

    @luacmartins
    ContributorAuthor

    The following reasons make me think that it's a purely performance related issue.

    I think this is correct. There's a noticeable delay between user input and state update, which was not present with setNativeProps since that updated the component directly. There's some discussion in this issue, but no conclusion yet. It seems like this performance regression is still experienced with Fabric enabled.

    we'll lose the feature that selects the search text when a option is selected

    I'm fine with this. FWIW we already have inconsistent behavior with the Split Bill page for example, where selecting a participant completely clears the input.

    iou.mov
  12. roryabraham commented on Oct 6, 2022

    @roryabraham
    Contributor

    we'll lose the feature that selects the search text when a option is selected

    Agree that this is an acceptable cost.

    It seems like this performance regression is still experienced with Fabric enabled.

    Agree, though it might be possible that this performance regression could be further alleviated by using startTransition instead of setState (only possible after Fabric upgrade)

  13. rushatgabhane commented on Oct 7, 2022

    @rushatgabhane
    Member

    Can't promise anything, but I'm going try looking into this a bit

    @roryabraham I know that you're looking into this, but it looks like we all agree that solution # 1 (get rid of controlled selection) is the way to go.

    Please let me know if I should create a PR to replace controlled selection with clearing the input (as shown here #11053 (comment))

  14. luacmartins commented on Oct 7, 2022

    @luacmartins
    ContributorAuthor

    @rushatgabhane yes, let's move on with getting rid of controlled selection.

  15. roryabraham commented on Oct 7, 2022

    @roryabraham
    Contributor

    I don't feel great about losing that feature, let's be sure to create a follow-up issue to try re-implementing after Fabric is enabled

  16. rushatgabhane commented on Oct 7, 2022

    @rushatgabhane
    Member

    I don't feel great about losing that feature, let's be sure to create a follow-up issue to try re-implementing after Fabric is enabled

    Tracking issue #11679

  17. hannojg commented on Oct 10, 2022

    @hannojg
    Contributor

    Hey, just want to add to the discussion that TextInputs have an undocumented function called setSelection (I am not sure, but for web it might be named setSelectionRange), so you can call e.g.:

    this.textInputRef.setSelection(start, end)

    This way we can avoid having controlled inputs which are bad for performance + preserve the highlight functionality.

    (note: sorry if I am writing out of context, was just quickly glimpsing and thought this information might adds value)

  18. rushatgabhane commented on Oct 11, 2022

    @rushatgabhane
    Member

    Thanks, that's very helpful @hannojg!

    @luacmartins @roryabraham this.textInputRef.setSelection works perfectly on native.

    However setSelectionRange doesn't work on web. It prevents me from selecting rows!!

    Spent time on this, but I'm not sure what I'm not wrong.
    Would you mind picking this task, I'm not able to make progress on making it work on web.

    Screen.Recording.2022-10-11.at.9.17.36.PM.mov
  19. hannojg commented on Oct 11, 2022

    @hannojg
    Contributor

    Yes, i can give it a shot, although I am heavily focused on mobile, but will def try!

  20. hannojg commented on Oct 11, 2022

    @hannojg
    Contributor

    Sorry @rushatgabhane but where is the PR where you started working on it? Would like to continue from there

  21. rushatgabhane commented on Oct 11, 2022

    @rushatgabhane
    Member

    @hannojg my bad, I had made a typo 🤦‍♂️😭

    setSelection for native and setSelectionRange for web work great! 🎉
    Thanks again for the help :)

  22. stitesExpensify commented on Oct 17, 2022

    @stitesExpensify
    Contributor

    Not sure why this isn't closed, but we can close it! #8503 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions