Skip to content

Commit

Permalink
fix: Deprecate options.tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
elenajdanova committed Jun 25, 2024
1 parent c43b5f2 commit 6fae156
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 37 deletions.
20 changes: 18 additions & 2 deletions src/controls/TextControl.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,24 @@ test("renders tooltips", async () => {
scope: "#/properties/name",
label: "Name",
options: {
tooltip:
"Choose <a href='https://wheelofnames.com/' target='_blank' rel='noopener noreferrer'>a random name</a>.",
formItemProps: {
tooltip: {
title: (
<p>
Choose{" "}
<a
href="https://wheelofnames.com/"
target="_blank"
rel="noopener noreferrer"
>
a random name
</a>
.
</p>
),
placement: "right",
},
},
},
},
],
Expand Down
47 changes: 13 additions & 34 deletions src/stories/controls/TextControl.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,19 @@ export const FormItemTooltip: Story = {
label: "Name",
formItemProps: {
tooltip: {
title: "It's what you call yourself",
title: (
<p>
Choose{" "}
<a
href="https://wheelofnames.com/"
target="_blank"
rel="noopener noreferrer"
>
a random name
</a>
.
</p>
),
placement: "right",
},
},
Expand All @@ -148,36 +160,3 @@ export const FormItemTooltip: Story = {
} satisfies UISchema<typeof schema>,
},
}

export const OptionsTooltip: Story = {
parameters: { controls: { expanded: true } },
tags: ["autodocs"],
args: {
jsonSchema: schema,
uiSchema: {
type: "VerticalLayout",
elements: [
{
type: "Control",
scope: "#/properties/name",
label: "Name",
options: {
tooltip: (
<p>
Choose{" "}
<a
href="https://wheelofnames.com/"
target="_blank"
rel="noopener noreferrer"
>
a random name
</a>
.
</p>
),
},
},
],
} satisfies UISchema<typeof schema>,
},
}
5 changes: 4 additions & 1 deletion src/ui-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ export type AnyOfControlOptions = OneOfControlOptions
export type TextControlType = "multiline" | "password" | "singleline"

export type TextControlOptions = {
tooltip?: React.ReactNode
/**
* @deprecated Please use formItemProps.tooltip instead
*/
tooltip?: string
placeholderText?: string
required?: boolean
rules?: AntDRule[]
Expand Down

0 comments on commit 6fae156

Please sign in to comment.