Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .changeset/types-option-mrkdwn-description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@slack/types": patch
---

fix(types): allow `mrkdwn` descriptions on checkbox and radio button [options](https://docs.slack.dev/reference/block-kit/composition-objects/option-object)
23 changes: 15 additions & 8 deletions packages/types/src/block-kit/composition-objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,21 @@ interface OptionDescriptor {
* Maximum length for this field is 3000 characters.
*/
url?: string;
/**
* @description A {@link PlainTextElement} that defines a line of descriptive text shown below the `text` field.
* Maximum length for the `text` within this field is 75 characters.
*/
description?: PlainTextElement;
}

export interface MrkdwnOption extends OptionDescriptor {
/**
* @description A {@link MrkdwnElement} that defines the text shown in the option on the menu. To be used with
* radio buttons and checkboxes. Maximum length for the `text` in this field is 75 characters.
* @description A {@link PlainTextElement} or {@link MrkdwnElement} that defines the text shown in the option on the
* menu. To be used with radio buttons and checkboxes, which can use `mrkdwn` text objects. Maximum length for the
* `text` in this field is 75 characters.
*/
text: PlainTextElement | MrkdwnElement;
/**
* @description A {@link PlainTextElement} or {@link MrkdwnElement} that defines a line of descriptive text shown
* below the `text` field. Checkbox group and radio button group items can also use `mrkdwn` formatting. Maximum
* length for the `text` within this field is 75 characters.
*/
text: MrkdwnElement;
description?: PlainTextElement | MrkdwnElement;
}

export interface PlainTextOption extends OptionDescriptor {
Expand All @@ -99,6 +101,11 @@ export interface PlainTextOption extends OptionDescriptor {
* overflow, select and multi-select menus. Maximum length for the `text` in this field is 75 characters.
*/
text: PlainTextElement;
/**
* @description A {@link PlainTextElement} that defines a line of descriptive text shown below the `text` field.
* Maximum length for the `text` within this field is 75 characters.
*/
description?: PlainTextElement;
}

/**
Expand Down
82 changes: 81 additions & 1 deletion packages/types/test/block-elements.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { expectAssignable, expectError } from 'tsd';
import type { Button, RichTextInput, WorkflowButton } from '../src/index';
import type {
Button,
Checkboxes,
Overflow,
RadioButtons,
RichTextInput,
StaticSelect,
WorkflowButton,
} from '../src/index';

// RichTextInput — happy paths
expectAssignable<RichTextInput>({
Expand Down Expand Up @@ -56,3 +64,75 @@ expectAssignable<Button>({
agent_prompt_display: 'Summarize this incident',
visible_to_user_ids: ['U123456'],
});

// Checkboxes option with a mrkdwn description
expectAssignable<Checkboxes>({
type: 'checkboxes',
options: [
{
value: 'A2',
text: {
type: 'plain_text',
text: 'Checkbox 2',
},
description: {
type: 'mrkdwn',
text: '*A description of option two*',
},
},
],
});

// RadioButtons option with a mrkdwn description
expectAssignable<RadioButtons>({
type: 'radio_buttons',
options: [
{
value: 'A2',
text: {
type: 'plain_text',
text: 'Radio 2',
},
description: {
type: 'mrkdwn',
text: '*A description of option two*',
},
},
],
});

// Overflow option descriptions are plain_text only
expectError<Overflow>({
type: 'overflow',
options: [
{
value: 'A2',
text: {
type: 'plain_text',
text: 'Option 2',
},
description: {
type: 'mrkdwn',
text: '*A description of option two*',
},
},
],
});

// StaticSelect option descriptions are plain_text only
expectError<StaticSelect>({
type: 'static_select',
options: [
{
value: 'A2',
text: {
type: 'plain_text',
text: 'Option 2',
},
description: {
type: 'mrkdwn',
text: '*A description of option two*',
},
},
],
});
Loading