facebook / docusaurus

Easy to maintain open source documentation websites.
https://docusaurus.io
MIT License
55.8k stars 8.36k forks source link

Unable to use 2 same TabItem values #9474

Closed monica-m-ps closed 11 months ago

monica-m-ps commented 11 months ago

Have you read the Contributing Guidelines on issues?

Prerequisites

Description

I have a situation where I need to demonstrate the json code of two types, NoShow and Unscheduled.

<Tabs groupId="codeGroup">
<TabItem value="json" label="NoShow">

```json
{  ...
    "MerchantInitiatedTransactionType": "NoShow",
}

```json { ... "MerchantInitiatedTransactionType": "Unscheduled", } ```


I am unable to use json for both. I need to use the same language across both scenarios representing them in tabs.

### Reproducible demo

_No response_

### Steps to reproduce

1. In you markdown file, use the following code

````jsx
<Tabs groupId="codeGroup">
<TabItem value="json" label="NoShow">

```json
{  ...
    "MerchantInitiatedTransactionType": "NoShow",
}

```json { ... "MerchantInitiatedTransactionType": "Unscheduled", } ```



### Expected behavior

Expected to have two tabs "NoShow" and "Unscheduled" with the json code.

### Actual behavior

Getting an error Error: 
`Docusaurus error: Duplicate values "json" found in <Tabs>. Every value needs to be unique.`

### Your environment

- Public source code:
- Public site URL: locally built
- Docusaurus version used: 2.0.x
- Environment name and version (e.g. Chrome 89, Node.js 16.4): Not relevant
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): MacOs, yet not relevant

### Self-service

- [ ] I'd be willing to fix this bug myself.
Josh-Cena commented 11 months ago

What is your intended effect? Show two tab items simultaneously?

monica-m-ps commented 11 months ago

I understand Docusaurus doesn't support it. But can you add it as an enhancement please? Because my case is valid here.

Yes I want to add two tabitems but of the same language

Josh-Cena commented 11 months ago

value is not for displaying the language. value is purely a unique identifier to identify the tab. Underlyingly, Docusaurus is going to record that "whenever I see a tab with the group codeGroup, I'm going to display the item with value json, regardless of its label". You can change every occurrence of "json" to "myJson" and the effect is exactly the same. What do two identical values mean?

Josh-Cena commented 11 months ago

Are you reading our docs section "Multi-language support code blocks"? Would it help if the examples look like this?

<Tabs>
<TabItem value="1" label="JavaScript">

```js
function helloWorld() {
  console.log('Hello, world!');
}

```py def hello_world(): print("Hello, world!") ``` ```java class HelloWorld { public static void main(String args[]) { System.out.println("Hello, World"); } } ```



You can even forgo the values in this case—they were from a time when `value` was mandatory.
monica-m-ps commented 11 months ago

Ok, got it. I can display both of them regardless of their values. This makes sense. Thanks! Closing this case