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

a11y(Tooltip): "tooltip" role #6865

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from

Conversation

bvandercar-vt
Copy link
Contributor

Fixes #0000

Checklist

  • Includes tests
  • [N/A] Update documentation

Changes proposed in this pull request:

@changelog-app
Copy link

changelog-app bot commented Jun 25, 2024

Generate changelog in packages/core/changelog/@unreleased

What do the change types mean?
  • feature: A new feature of the service.
  • improvement: An incremental improvement in the functionality or operation of the service.
  • fix: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way.
  • break: Has the potential to break consumers of this service's API, inclusive of both Palantir services
    and external consumers of the service's API (e.g. customer-written software or integrations).
  • deprecation: Advertises the intention to remove service functionality without any change to the
    operation of the service itself.
  • manualTask: Requires the possibility of manual intervention (running a script, eyeballing configuration,
    performing database surgery, ...) at the time of upgrade for it to succeed.
  • migration: A fully automatic upgrade migration task with no engineer input required.

Note: only one type should be chosen.

How are new versions calculated?
  • ❗The break and manual task changelog types will result in a major release!
  • 🐛 The fix changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease.
  • ✨ All others will result in a minor version release.

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

a11y(Tooltip): "tooltip" role

Check the box to generate changelog(s)

  • Generate changelog entry

Copy link
Contributor

@evansjohnson evansjohnson left a comment

Choose a reason for hiding this comment

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

I think we should be able to get something merged here but we should be careful here of any chance of breaking existing behavior and overriding props passed to these components.

packages/core/src/common/utils/reactUtils.ts Outdated Show resolved Hide resolved
packages/core/src/components/tooltip/tooltip.tsx Outdated Show resolved Hide resolved
const tooltipId = Utils.uniqueId("tooltip");

const childTarget = Utils.ensureElement(React.Children.toArray(children)[0], undefined, {
"aria-describedby": tooltipId,
Copy link
Contributor

Choose a reason for hiding this comment

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

could we try some version of facebook/react#8205 (comment) and checking hasOwnProperty to make sure we're not overriding an id specified by a consumer of Tooltip?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually aria-describedby can have multiple values as a space separated list string (https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby). Updated to concatenate that if passed: 730d177

packages/core/test/tooltip/tooltipTests.tsx Show resolved Hide resolved
@evansjohnson evansjohnson self-assigned this Jun 26, 2024
Copy link
Contributor

@evansjohnson evansjohnson left a comment

Choose a reason for hiding this comment

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

I think this is getting closer but we need to be very careful here of breaking existing behavior. We'll only be able to merge this if this can be done in a way that is a strict improvement, and doesn't negatively impact users who may have already done the work to work around this.

packages/core/src/components/tooltip/tooltip.tsx Outdated Show resolved Hide resolved
// want Popover to warn if empty, so don't wrap in element if empty.
Utils.isReactNodeEmpty(content)
? content
: Utils.ensureElement(content, undefined, { role: "tooltip", id: tooltipId })
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we can do this because a consumer may have already defined an id on the content which this would override

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Highly doubt that would ever be the case, can't imagine what other scenarios they'd be doing this for. There are many cases, such as in Popover, where we apply a bunch of props without caring what the consumer may have already applied.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should account for that case: be12eb3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@evansjohnson the other alternative solution here would be we add a prop contentProps to Popover and apply it to the div that's already wrapping the content. Then we could apply these props via that. Up to you.

@@ -252,7 +247,8 @@ export class Popover<
const { disabled, content, placement, position = "auto", positioningStrategy } = this.props;
const { isOpen } = this.state;

const isContentEmpty = content == null || (typeof content === "string" && content.trim() === "");
const isContentEmpty =
Copy link
Contributor

Choose a reason for hiding this comment

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

this change means the empty check will be hit if the content is false or [], which seems like a good change. previously I imagine we tried to render the popover but it ended up not really displaying anything. I can't imagine anyone would want the current behavior.

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

Successfully merging this pull request may close these issues.

None yet

2 participants