Skip to content

feat(Focus): Add global focus state

Jeremy Elder requested to merge 1035-add-global-focus-state into master

What does this MR do?

Some of our elements have custom focus styles, while others get browser defaults. This fixes it by:

  • Modify focus stategl-focus mixin and related variables.
  • Ensure the the mixin is applied for all components and elements that can receive focus.

Note: All updates are visual only, and not functional.


Example focused components Specs
image CleanShot_2020-12-22_at_13.54.12_2x
Before After Notes
CleanShot_2020-12-23_at_09.21.30 CleanShot_2020-12-23_at_09.22.15 The focus ring is actually removed on the parent anchor, and moved to the image within so that the focus ring can wrap the avatar shape.
CleanShot_2020-12-23_at_09.24.33 CleanShot_2020-12-23_at_09.24.03 Badges still use the lighter inner ring to better offset the pastel colors.
CleanShot_2020-12-23_at_09.27.03 CleanShot_2020-12-23_at_09.27.36
CleanShot_2020-12-23_at_09.28.54 CleanShot_2020-12-23_at_09.30.03
CleanShot_2020-12-23_at_09.32.17 CleanShot_2020-12-23_at_09.31.59 Not able to move keyboard focus into the calendar panel. Focus also seems to disappear when moving between two inputs in the Daterange picker. #1103 created to investigate.
CleanShot_2020-12-23_at_09.34.53 CleanShot_2020-12-23_at_09.35.29 Panel has overflow-y set to auto, so that means that overflow-x is automatically auto as well and the focus ring of the menu item gets clipped on the sides. See #1102 (closed) for proposed solution.
CleanShot_2020-12-23_at_09.38.41 CleanShot_2020-12-23_at_09.39.15 Not updated to use custom controls yet. #862 (closed)
CleanShot_2020-12-23_at_09.41.28 CleanShot_2020-12-23_at_09.41.48 Not updated to use custom controls yet. #862 (closed)
CleanShot_2020-12-23_at_09.43.34 CleanShot_2020-12-23_at_09.44.10
CleanShot_2020-12-23_at_09.45.39 CleanShot_2020-12-23_at_09.46.17 Valid and invalid states will now appear just like the other variants, although invalid could be updated to have the red inner border in the future. #1105 (closed) created to update the border color.
CleanShot_2020-12-23_at_09.50.54 CleanShot_2020-12-23_at_09.51.19 The CSS variable is able to be used for all of the labels so that the inner border (box-shadow) can still match the user generated color.
CleanShot_2020-12-23_at_09.51.55 CleanShot_2020-12-23_at_09.52.35 The underline for the scoped text isn’t visible and should be in a future update. #1106 (closed) created to make the underline visible.
CleanShot_2020-12-23_at_09.53.36 CleanShot_2020-12-23_at_09.53.08 The × button isn’t using the gl-button so right now it doesn’t get those focus styles but will once the component is updated to use the new button. #1104 (closed) created to update the button.
CleanShot_2020-12-23_at_09.58.24 CleanShot_2020-12-23_at_09.58.47
CleanShot_2020-12-23_at_10.00.02 CleanShot_2020-12-29_at_10.29.12 Pagination styles updated to match the design specs.
CleanShot_2020-12-23_at_10.01.53 CleanShot_2020-12-23_at_10.02.18 Focus styles applied, but overflow hidden on both the li and ul prevents it from really being seen. I think this is one that could use a separate declaration since it also has the ::after element to create the point. See #1102 (closed) for proposed solution.
CleanShot_2020-12-23_at_10.05.40 CleanShot_2020-12-23_at_10.05.57 Hover, focus, and active styles need updated to look more like their button counterparts, but this will be handled in a separate MR. Issue #1000 (closed) exists to address.
CleanShot_2020-12-23_at_10.07.23 CleanShot_2020-12-23_at_10.13.13
CleanShot_2020-12-23_at_10.14.52 CleanShot_2020-12-23_at_10.15.11 The focus ring here is animated because @include gl-transition-slow is used which animates all properties. This could be changed in the future to make the focus state more instant and noticeable. #1101 created to address.

Out of scope

  • Dark UI
  • Markdown links
  • Items with default Bootstrap or third-party styles, like the Carousel or Nav and Navbar

Relates to gitlab-org/gitlab-services/design.gitlab.com#607 (closed)

Does this MR meet the acceptance criteria?

Conformity

  • Code review guidelines.
  • GitLab UI's contributing guidlines.
  • If it changes a Pajamas-compliant component's look & feel, the MR has been reviewed by a UX designer.
  • If it changes GitLab UI's documentation guidelines, the MR has been reviewed by a Technical Writer.
  • If the MR changes a component's API, integration MR(s) have been opened in the following projects to ensure that the @gitlab/ui package can be upgraded quickly after the changes are released:
  • Added the ~"component:*" label(s) if applicable.

Security

N/A

Closes #1035 (closed)

Edited by Jeremy Elder

Merge request reports