Skip to content

Commit

Permalink
feat: add text selection ability for disabled legacy editable header
Browse files Browse the repository at this point in the history
  • Loading branch information
moro256 committed Apr 14, 2024
1 parent d3335ce commit b92ad30
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/core/src/components/Clickable/Clickable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ const Clickable: VibeComponent<ClickableProps, HTMLElement> = forwardRef(
ariaLabel,
ariaHidden,
ariaHasPopup,
ariaExpanded
ariaExpanded,
enableTextSelection
},
ref
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface EditableHeadingProps extends EditableInputProps, HeadingProps {
tooltip?: string;
insetFocus?: boolean;
contentRenderer?: React.FC;
enableTextSelection?: boolean;
}

/**
Expand Down Expand Up @@ -67,7 +68,8 @@ const LegacyEditableHeading: React.FC<EditableHeadingProps> & {
size = HeadingSizes.LARGE,
displayPlaceholderInTextMode = true,
suggestEditOnHover = true,
type = Heading.types.h1
type = Heading.types.h1,
enableTextSelection = false
} = props;

const overrideDataTestId = backwardCompatibilityForProperties([dataTestId, backwardCompatabilityDataTestId]);
Expand Down Expand Up @@ -211,7 +213,8 @@ const LegacyEditableHeading: React.FC<EditableHeadingProps> & {
onIgnoreBlurEvent: onIgnoreBlurEventCallback,
onError: onInputErrorCallback,
onSuccess: onInputSuccessCallback,
ariaLabel: props.inputAriaLabel
ariaLabel: props.inputAriaLabel,
enableTextSelection
};
};

Expand All @@ -234,7 +237,12 @@ const LegacyEditableHeading: React.FC<EditableHeadingProps> & {
id={id}
data-testid={overrideDataTestId || getTestId(ComponentDefaultTestId.EDITABLE_HEADING, id)}
>
<Clickable role={shouldEdit ? "button" : "input"} onClick={onClick} disabled={disabled}>
<Clickable
role={shouldEdit ? "button" : "input"}
onClick={onClick}
disabled={disabled}
enableTextSelection={enableTextSelection}
>
{shouldEdit ? renderInputComponent() : renderContentComponent()}
</Clickable>
</div>
Expand Down

0 comments on commit b92ad30

Please sign in to comment.