Skip to content

Dropdown arrow not visible when body background colour is white (e.g. in govuk-frontend) #351

Open
@andymantell

Description

@andymantell

I have encountered an issue when attempting to use the accessible-autocomplete under the new govuk design system, which sets background-color to white on the body element - meaning that the arrow is no longer visible.

This is caused by the z-index: -1 on the arrow effectively putting it underneath the body element. Which relies on the body having a transparent background colour which is no longer true in the new govuk-design-system (It used to be fine under govuk-elements / govuk-frontend-toolkit)

We have fixed it for our purposes by removing z-index: -1 from the arrow. In order for the clicks to pass through to the underlying input, we then use pointer-events: none on the arrow. Due to browser support for pointer-events, we then withhold the enhanced select from IE10 by detecting pointer events support using this little snippet:

function supportsPointerEvents() {
  var element = document.createElement('x');
  element.style.cssText = 'pointer-events:auto';
  return element.style.pointerEvents === 'auto';
}

(Somewhat related issue here that may also warrant use of pointer-events: #227)

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't working the way it should (including incorrect wording in documentation)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions