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

feat(feedback): Trigger button aria label configuration #13008

Merged
merged 3 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/feedback/src/core/components/Actor.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { DOCUMENT } from '../../constants';
import { DOCUMENT, TRIGGER_LABEL } from '../../constants';
import { createActorStyles } from './Actor.css';
import { FeedbackIcon } from './FeedbackIcon';

export interface ActorProps {
triggerLabel: string;
triggerAriaLabel: string;
shadow: ShadowRoot;
}

Expand All @@ -22,12 +23,12 @@ export interface ActorComponent {
/**
* The sentry-provided button to open the feedback modal
*/
export function Actor({ triggerLabel, shadow }: ActorProps): ActorComponent {
export function Actor({ triggerLabel, triggerAriaLabel, shadow }: ActorProps): ActorComponent {
const el = DOCUMENT.createElement('button');
el.type = 'button';
el.className = 'widget__actor';
el.ariaHidden = 'false';
el.ariaLabel = triggerLabel;
el.ariaLabel = triggerAriaLabel || triggerLabel || TRIGGER_LABEL;
el.appendChild(FeedbackIcon());
if (triggerLabel) {
const label = DOCUMENT.createElement('span');
Expand Down
4 changes: 3 additions & 1 deletion packages/feedback/src/core/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const buildFeedbackIntegration = ({
submitButtonLabel = SUBMIT_BUTTON_LABEL,
successMessageText = SUCCESS_MESSAGE_TEXT,
triggerLabel = TRIGGER_LABEL,
triggerAriaLabel = '',

// FeedbackCallbacks
onFormOpen,
Expand All @@ -124,6 +125,7 @@ export const buildFeedbackIntegration = ({
themeLight,

triggerLabel,
triggerAriaLabel,
cancelButtonLabel,
submitButtonLabel,
confirmButtonLabel,
Expand Down Expand Up @@ -258,7 +260,7 @@ export const buildFeedbackIntegration = ({
const _createActor = (optionOverrides: OverrideFeedbackConfiguration = {}): ActorComponent => {
const mergedOptions = mergeOptions(_options, optionOverrides);
const shadow = _createShadow(mergedOptions);
const actor = Actor({ triggerLabel: mergedOptions.triggerLabel, shadow });
const actor = Actor({ triggerLabel: mergedOptions.triggerLabel, triggerAriaLabel: mergedOptions.triggerAriaLabel, shadow });
_attachTo(actor.el, {
...mergedOptions,
onFormOpen() {
Expand Down
5 changes: 5 additions & 0 deletions packages/types/src/feedback/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ export interface FeedbackTextConfiguration {
*/
triggerLabel: string;

/**
* The aria label for the Feedback widget button that opens the dialog
*/
triggerAriaLabel: string;

/**
* The label for the Feedback form cancel button that closes dialog
*/
Expand Down
Loading