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

chore: Extracting out common logic between two ADS components to move it to one #38885

Merged
merged 8 commits into from
Jan 31, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const Basic: Story = {
dataTestId: "t--dismissible-tab",
icon: JSIcon(),
name: "Hello",
canEdit: true,

onNameSave: console.log,
validateName: (name: string) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { EditableDismissibleTabProps } from "./EditableDismissibleTab.types

export const EditableDismissibleTab = (props: EditableDismissibleTabProps) => {
const {
canEdit,
dataTestId,
icon,
isActive,
Expand Down Expand Up @@ -38,6 +39,7 @@ export const EditableDismissibleTab = (props: EditableDismissibleTabProps) => {
onDoubleClick={handleDoubleClick}
>
<EditableEntityName
canEdit={canEdit}
icon={icon}
isEditing={isEditing}
isLoading={isLoading}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export interface EditableDismissibleTabProps {
onClose: () => void;
onNameSave: (name: string) => void;
validateName: (name: string) => string | null;
canEdit?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ export const Root = styled.div`

export const Text = styled(ADSText)`
min-width: 3ch;

& input {
background-color: var(--ads-v2-color-bg);
padding-top: 4px;
padding-bottom: 4px;
top: -5px;
}
line-height: normal;

&[data-isfixedwidth="true"] {
white-space: nowrap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { EditableEntityNameProps } from "./EditableEntityName.types";
export const EditableEntityName = (props: EditableEntityNameProps) => {
const {
canEdit,
icon,
inputTestId,
isEditing,
isFixedWidth,
Expand Down Expand Up @@ -43,15 +44,21 @@ export const EditableEntityName = (props: EditableEntityNameProps) => {
return <Spinner size={size === "small" ? "sm" : "md"} />;
}

return props.icon;
}, [isLoading, props.icon]);
return icon;
}, [isLoading, icon]);

const inputProps = useMemo(
() => ({
["data-testid"]: inputTestId,
onKeyUp: handleKeyUp,
onChange: handleTitleChange,
autoFocus: true,
style: {
backgroundColor: "var(--ads-v2-color-bg)",
paddingTop: "4px",
paddingBottom: "4px",
top: "-5px",
},
}),
[handleKeyUp, handleTitleChange, inputTestId],
);
Expand Down

This file was deleted.

Loading