Stop the Semantic UI Dropdown from updating the displayed content

I am currently utilizing this Dropdown feature from Semantic UI, and I have a query regarding maintaining the top section unchanged even after selecting an option.

In the example provided by Semantic UI, the default selection is Gender; however, when one selects Male or Female, the displayed text changes to reflect the chosen value.

Is there a way to prevent this change so that the dropdown always displays "Gender," regardless of the selected option?

Here is the code snippet:

import Dropdown from '../Dropdown.component';

<Dropdown // Customized Dropdown based on Semantic UI
  className="hello-dropdown"
  placeholder="Company"
  onChange={this.doSomething}
  options={someOptions}
/>;

Dropdown.component

import React from 'react';
import { Dropdown } from 'semantic-ui-react';

import './Dropdown.styles.scss';

export default ({ placeholder, options, onChange, name, className }) => (
  <Dropdown
    className={className}
    name={name}
    placeholder={placeholder}
    search
    selection
    options={options}
    onChange={onChange}
    clearable
  />
);

I suspect the solution lies within the placeholder={placeholder} attribute, but I'm not entirely sure.

Answer №1

To display the placeholder text constantly, you can assign an empty string to the value prop of the Dropdown component:

// ...
<Dropdown
  className={className}
  name={name}
  placeholder={placeholder}
  value=""
  search
  selection
  options={options}
  onChange={onChange}
  clearable
/>
// ...

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

extracting information from a webpage with Php

While the task at hand is straightforward, I am looking to incorporate a form to retrieve the URLs needed. Initially, I utilized file_get_contents but later transitioned to fopen. <?php $page = $_GET['page']; $marki = fopen($page, "rb"); ec ...

The webpage is functioning properly when accessed through localhost, but it is not working on Firebase or Netlify

Encountering a problem while trying to deploy my react app, even though I have successfully used firebase hosting in the past without any issues. Currently working on a simple news app using react, everything runs smoothly when testing it on localhost. H ...

Leveraging Firebase and Cloud Functions to dynamically update values based on date conditions

In my database, I have a collection of consultations with the value 'date' in TimeStamp format (e.g. October 31, 2020 at 1:00:00 AM UTC+1) and another value called "status" which is either true or false. Each TimeStamp always has the same time - ...

What is the best method for summing the numerical values of a JSON array?

I have a task to calculate the sum and average of integer values from an Array object. Here is the input array: Input: [ {"string": "John", "integer": 7}, {"string": "Margot", "integer& ...

Error: Bootstrap 4 Container Size Issue

I am having an issue with the width of my footer when using a Bootstrap 4 "Container". The Container does not cover the entire bottom of the screen as expected. Even changing it to Container-Fluid does not resolve the issue. For reference, here is a JSFid ...

Trouble with reading from a newly generated file in a node.js program

Whenever I launch my results.html page, I generate a new JSON file and use express.static to allow access to the public folder files in the browser. Although my application is functioning properly, I find myself having to click the button multiple times f ...

Arranging the output of a service in Angular

After running my post function, I need to sort the result. Here is the post function: findQuotation(queryParams: QueryParamsModel): Observable<QueryResultsModel> { return this.http.post<QueryResultsModel>(API_QUOTATIONS_URL + '/li ...

Create a single declaration in which you can assign values to multiple const variables

As a newcomer to react/JS, I have a question that may seem basic: I need multiple variables that are determined by a system variable. These variables should remain constant for each instance. Currently, my approach is functional but it feels incorrect to ...

Transforming substantial quantities of data into a string array in JavaScript

I have around 2000 items of data that I work with on a regular basis in Visual Studio Code. Is there a way to convert this data into a string array without having to manually add quotes around each item using JavaScript? var array = [ a2kjda a2dkj ...

Implementing dynamic title insertion into a popover element using jQuery

My goal is to assign a title to my popover object in a local project. I have already included the following files: bootstrap.css v4.2.1 jquery.min.js v2.2.0 bootstrap.min.js v4.2.1 popper.min.js v1.11.0 Initially, there was a basic button present. <i ...

Exciting feature: Changing text color dynamically with Sass

Is it possible to create a mixin that sets text color based on the background? It seems straightforward with one color, but how about when there are two colors or changing the color of half of the text? Try changing the text with a blue background.. http ...

The user provided an OIDC authentication endpoint for an Expo React Native app

I'm working on creating an application that can connect to different oidc endpoints based on user input of a URI. I've been searching for information on how to modify or update the 'expo-auth-session' useAuthRequest method without any ...

Is there a way to delay the closing of the browser until the server call is finished?

I am attempting to invoke a service that updates data upon browser close or tab close. The issue I am facing is that the service call uses $http and is asynchronous, so I believe that the browser unload event is cancelling the call and closing the browser. ...

What is the best way to smoothly add or remove several classes to a div while scrolling?

Looking for assistance to create a fading effect where a logo fades out and a smaller version fades in as I scroll. The scaling aspect is currently functioning correctly on scroll (view JS Fiddle), but the fading transition needs some work, resulting in ch ...

Guidelines for passing multiple Javascript values to a C# action method

Assuming I have a piece of JavaScript code similar to the one shown in the image. I populate an array with multiple values and then pass this array to an action method in a controller. However, in the action method, I receive this array as an 'object& ...

Submit information collected from Facebook using a form

I'm attempting to transfer data from an HTML page to a PHP page. The data is coming from a JavaScript variable. Situation: I am in the process of creating a Facebook login page. I have obtained data from a FB script and need to send a name to another ...

Tips for emphasizing a row of various list boxes when hovering in asp.net

I am facing an issue with two listboxes on my website. Currently, I can only highlight one item at a time by mousing over the listbox. However, I would like to be able to highlight items in both listboxes simultaneously when I mouseover either listbox1 or ...

Experience the convenience of streaming MP3 files directly through the HTML5 audio tag, eliminating the need

Within the function document.ready, I have included the following code snippet: audioElement = document.createElement('audio'); audioElement.setAttribute('src', 'http://www.mfiles.co.uk/mp3-downloads/Toccata-and-Fugue-Dm.mp3&apos ...

Is it possible to have a ListItem containing non-ListItem elements as its children?

I am in need of a React component similar to the ones on your website: IMAGE What I'm looking for is a band with a title and a button on the right. When you click on this button, it should open a dropdown component where I can call other components ...

Creating a div that becomes fixed at the top of the page after scrolling down a certain distance is a great way to improve user experience on a

I am struggling to create a fixed navigation bar that sticks to the top of the page after scrolling 500px, but without using position: fixed. Despite trying various solutions, none seem to work due to the unique layout of my navigation bar. Strangely enoug ...