Skip to content
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

Select: Weird bug with options state #208

Open
edizcelik opened this issue Nov 9, 2022 · 0 comments · May be fixed by #227
Open

Select: Weird bug with options state #208

edizcelik opened this issue Nov 9, 2022 · 0 comments · May be fixed by #227
Assignees
Labels
bug Something isn't working

Comments

@edizcelik
Copy link
Contributor

edizcelik commented Nov 9, 2022

On Tinyman, we have this situation:

  • We use Select to render a dropdown menu on a table row to give users a menu of additional actions that they can take.

Screen Shot 2022-11-09 at 15 40 50

  • These menu options are dynamically determined. For example, "view farms" option only show up if that particular pool has farming programs. To be able to determine that, we make a request to fetch farming programs for the pool on that row. So, we have 6 options when Select component first renders, then we update the options to add "view farms" option. However, this change in "options" prop is not reflected on SelectContext's state. There are still 6 items (options other than "view farms") within the SelectContext's options state. And, this leads to all sorts of strange behaviors. For example, when the menu is first opened, "view farms" is highlighted as if it was the focused item but focusedOptionIndex is still -1. Also, "view farms" option is skipped when navigating between options with the keyboard arrows since it isn't included in SelectContext.

We solved this by waiting the async process to complete until we render the Select component. After that it works as expected, ie. SelectContext's options state has all 7 options as expected.

@gulcinuras gulcinuras self-assigned this Nov 16, 2022
@gulcinuras gulcinuras linked a pull request Feb 20, 2023 that will close this issue
@jamcry jamcry added the bug Something isn't working label Jan 15, 2024
@gulcinuras gulcinuras linked a pull request Apr 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants