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

Code Insights: Improve dashboard select UI #43029

Merged
merged 19 commits into from
Oct 20, 2022
Merged

Conversation

vovakulikov
Copy link
Contributor

@vovakulikov vovakulikov commented Oct 17, 2022

Problem

This PR improves dashboard select UI on the code insight dashboard page. Previously this select was built with Listbox UI from reach-ui. And it was good enough but we had a few problems with

  • Keyboard navigation since listbox doesn't work well with anything that is not listbox component (it's bad because we want to have search filter input within listbox popover)
  • Listbox options accessibility. Keyboard navigation doesn't support scroll into view functionality for focused/active listbox options.
  • Listbox Popover has to be fixed size and doesn't have smart position logic that we have with out in-house popover component
  • Filter highlighting logic, we want to highlight parts that match with filter value in the input and we had to write this logic ourselves back then.

Solution

In this PR we replace Listbox UI with combination of wildcard Popover and Combobox UI. This gives us better UI/UX.

Screenshot 2022-10-17 at 18 11 14

  • Better keyboard navigation. All options are accessible from keyboard. It works nicely with search filter input (it has autocompletion as you navigate through options)
  • Better Popover logic. We use our in-house popover this means that select UI popover will fit in the visible viewport area based on content and available area below the select element.
  • Slightly updated UI. Dashboard select UI is built now with more or less the same layout concept as all other comboboxes in the app. (Like SearchContextPicker on the home page)

Tradeoffs

  • Since Combobox UI works only with unique strings we can't have dashboard with the same names in the options list. Because of this this PR enforces unique dashboard names by adding (1), (2), ... (N) suffix (example: Insights dashboard, Insights dashboard become Insights dashboard (1) and Insights dashboard (2))
  • If you have selected dashboard and then you open the dashboard select popover you will see that search input has its name as a value. This is done for a better keyboard navigation (TL;DR it's reach-ui problem). This is the only way to enforce that keyboard navigation starts with selected element and not from the very beginning of the options list. More details in the reach-ui issues about it Combobox: Make it possible to set initial navigationValue  reach/reach-ui#979

Test plan

  • Make sure that you can pick any dashboard that you can see in the dashboard select UI
  • Check that all dashboard options are accessible from keyboard
  • Check that dashboard select popover is placed in the right position in different screen sizes.
  • Check that long dashboard names are handled properly (truncated) in select trigger button and in combobox options

App preview:

Check out the client app preview documentation to learn more.

@vovakulikov vovakulikov self-assigned this Oct 17, 2022
@cla-bot cla-bot bot added the cla-signed label Oct 17, 2022
@sg-e2e-regression-test-bob
Copy link

Bundle size report 📦

Initial size Total size Async size Modules
-0.08% (-2.25 kb) -0.16% (-24.23 kb) 🔽 -0.19% (-21.97 kb) 🔽 -0.41% (-3) 🔽

Look at the Statoscope report for a full comparison between the commits 893613a and 204ffb6 or learn more.

Open explanation
  • Initial size is the size of the initial bundle (the one that is loaded when you open the page)
  • Total size is the size of the initial bundle + all the async loaded chunks
  • Async size is the size of all the async loaded chunks
  • Modules is the number of modules in the initial bundle

@vovakulikov vovakulikov marked this pull request as ready for review October 17, 2022 21:14
@sourcegraph-bot
Copy link
Contributor

sourcegraph-bot commented Oct 17, 2022

Codenotify: Notifying subscribers in OWNERS files for diff 204ffb6...893613a.

Notify File(s)
@sourcegraph/frontend-platform-devs client/wildcard/src/components/Charts/core/components/tooltip/Tooltip.tsx
client/wildcard/src/components/Combobox/Combobox.module.scss
client/wildcard/src/components/Combobox/Combobox.tsx
client/wildcard/src/components/NavMenu/NavMenu.test.tsx
client/wildcard/src/components/Popover/Popover.tsx
client/wildcard/src/components/Popover/components/popover-content/PopoverContent.tsx
client/wildcard/src/components/Popover/tether/services/tether-registry.ts
client/wildcard/src/components/index.ts

Copy link
Contributor

@chwarwick chwarwick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The insights related changes look fine to me. I don't like that you need to append numbers to duplicate dashboard names and that they would be inconsistent between users.

@@ -46,7 +47,22 @@ export const getDashboards = (apolloClient: ApolloClient<unknown>, id?: string):
})
)

export function deserializeDashboardsOwners(
function makeDashboardTitleUnuque(dashboards: InsightsDashboardNode[]): InsightsDashboardNode[] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how I feel about this. I assume this would not be common, but also it's user specific so my Chris Dashboard might be your Chris Dashboard 2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're right that there is a possibility to have non-consistent dashboard names. I don't like this behaviour either. I did this because reach ui combobox doesn't work with non unique items. I think this problem is bad anyway (with number suffix or without)

  • I believe if someone wants to share a dashboard they would probably go with dashboard URL where we have unique id instead of copy past title
  • Even if we someone uses title as something for looking for a dashboard I think even without numbers it would confuse users, without number they will see different amount of dashboards, so inconsistent problem persists here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree two with the same name is just as bad so I don't consider this a blocker if the change brings other positive benefits.

@chwarwick
Copy link
Contributor

I haven't been able to get the web preview link to work for this, I get an error so I could try it to get a sense of how it feels to use aside from playing in the storybook, which worked well for me.

@vovakulikov
Copy link
Contributor Author

@chwarwick the web app link is broken because of redirect issue
The right link is https://sg-web-vk-improve-dashboard-select.onrender.com/search

@chwarwick
Copy link
Contributor

@chwarwick the web app link is broken because of redirect issue The right link is https://sg-web-vk-improve-dashboard-select.onrender.com/search

Thanks @vovakulikov that worked and I didn't have any issues with dashboard select. Not sure if it's related to this change but I keep getting stuck in the screen reader after changing dashboards it repeats "Loading, Loading, Loading.... ".

@vovakulikov
Copy link
Contributor Author

@chwarwick thanks for checking implementation! Yeah, this issue with loading state that's the infamous, here is an issue for this #41684

Copy link
Contributor

@AlicjaSuska AlicjaSuska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for making this improvement @vovakulikov! It works really nicely, the keyboard navigation is smooth. No issues from my side. Well done!

I've noticed that the three dots menu icon for dashboard context menu has the incorrect color:

  • it should be $icon-color
  • it is: $body-color in light mode
  • renders as a dark grey in dark mode, even though it has the $body-color color assigned

Screenshot 2022-10-20 at 16 16 59

I'm not sure if it's connected to any changes made in this PR, but could you please help to change this? Thank you!

Copy link
Contributor

@chwarwick chwarwick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the insights side 👍

@vovakulikov
Copy link
Contributor Author

Thanks for UI and tech review! The issue with three dot context menu and the dark theme is covered in a separate issue, I will address it in a next PR.

@vovakulikov vovakulikov merged commit 05b188c into main Oct 20, 2022
@vovakulikov vovakulikov deleted the vk/improve-dashboard-select branch October 20, 2022 22:15
@philipp-spiess philipp-spiess mentioned this pull request Oct 24, 2022
@philipp-spiess
Copy link
Member

It seems like this change has introduced an endless recursion in combination with the git blame view (maybe other views as well?): #43335 (comment)

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

Successfully merging this pull request may close these issues.

None yet

6 participants