Gone in a Blink: Options Slot Vanishing Act on Quasar Select

Currently, I am facing a challenge while working on a Vue component with a q-select. My requirement is to have a consistent button embedded inside the q-select. However, the issue arises when the select option includes a filter that determines the availability of options. As a result, whenever I apply a filter and there are no matching results, the button vanishes along with the functionality it provides. preview

<q-select
  ref="selectEntityRef"
  v-model="_value"
  :options="filteredItems"
  :label="_label || $t(entity?.defaultLabel) || ''"
  :multiple="_multiple"
  :debounce="_debounce"
  :disable="_disable"
  :readonly="_readonly"
  :rules="_rules"
  :dense="_dense || _ultraDense"
  :lazy-rules="_lazyRules"
  :hide-bottom-space="_hideBottomSpace"
  :loading="isLoading"
  :aria-placeholder="placeholder"
  :emit-value="!_returnObject"
  :clearable="_clearable"
  option-label="label"
  option-value="value"
  input-debounce="750"
  use-input
  outlined
  class="col col-grow small-icon text-ellipsis"
  @filter="filterItems"
  @focus="focused = true"
  @blur="blur"
  @input="emitObject"
  >
  <template v-slot:selected>
   <span
     class="text-neutral-primary-dark"
     v-html="placeholder"
   />
  </template>
  <template v-slot:option="scope">
   <q-item
     :data-test-id="getOptionId(scope)"
     v-bind="scope.itemProps"
     v-on="scope.itemEvents"
   >
     <q-item-section>
       <q-item-label v-html="scope.opt.label"/>
     </q-item-section>
   </q-item>
  </template>
  <template
   v-slot:after-options
  >
   <q-btn
     :label="'Something'"
     color="primary"
     icon="add"
     type="a"
     dense
     unelevated
     flat
     no-caps
     class="text-neutral-primary-dark q-ml-sm q-mb-sm q-mt-sm"
     @click="doSomething"
   >
     <q-tooltip
       :delay="300"
       anchor="bottom middle"
       self="top middle"
       transition-show="fade"
       transition-hide="fade"
     >
        "Some Text"
     </q-tooltip>
   </q-btn>
  </template>
</q-select>

My main goal is to ensure the persistence of the button even in scenarios where no options are available. How can I achieve this?

Answer №1

This specific problem has been brought to our attention previously (via the before-options slot, however the core issue remains): https://github.com/quasarframework/quasar/issues/8755

You can opt to utilize the distinct no-option slot instead, or implement the workaround outlined in the comments to trigger the menu to appear (although this is not the preferred approach)

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

Validating input in Angular UI Bootstrap Datepicker

I have integrated a datepicker from angular-ui/bootstrap. However, I am facing an issue where the user can freely type in the input field instead of selecting a date. Here is a snippet of my code: session.js session.getDateFormat = function() { ...

Tips for successfully passing multiple data IDs in a Bootstrap modal

Greetings! I am currently facing a challenge with passing multiple data IDs into a bootstrap modal. When I manually assign the data IDs, everything works perfectly: <a id="testB" href="#my_modal2" data-toggle="modal" data-book-id='{"id":10,"name ...

various operations in routes using Express.js

Hey there, I am new to express js and I am looking to include multiple functions within routes. Can someone explain how to add multiple functions within a route? I have 2 functions in company.js but I am unsure how to export and add them in index.js. Here ...

Navigating through the Jquery DOM to access a specific node

Displayed here are a list of products, presented within an unordered list: Users can express interest in specific items by clicking "I am Interested," prompting a change in background color and the appearance of a tick mark next to the selected item. To ...

Tips for wiping clean and restarting data in a modal?

After closing and reopening this modal, both the old information and new data remain. I aim to reset everything within the modal, wiping out details from both the header and body. Expected scenario - https://i.sstatic.net/Z42Rk.png Actual situation - http ...

What is the best way to programmatically insert new rows into a table

I am currently working with the foundation 5 framework (not sure if this is relevant). I need to ensure that each CELL is treated as a distinct item/value when passing information to another page, and I am unsure of how to approach this issue. It should cr ...

Ending the jQuery Modal box

Struggling to create a simple modal on my own, and I'm facing some difficulties (probably because I'm more of an expert in jQuery - but let's not dwell on that too much). This is the HTML markup I have: <div id="modal-boxes"> < ...

Is there a way to create a header that fades out or disappears when scrolling down and reappears when scrolling up?

After spending some time researching and following tutorials, I have not made much progress with my goal. The task at hand is to hide the top header of my website when the user scrolls down and then make it reappear when they scroll back up to the top of t ...

How can I pass a value as an attribute from an Angular template to a directive?

Here's a directive I'm working with: <g-map-locations center={{myLocation}} zoom="4" id="map" class="map"></g-map-locations> The zoom parameter is used in Angular to set the zoom level for a Google Map: attrs.zoom = zoom setMapOpti ...

Maintaining the consistent structure of build directories within a Docker container is crucial, especially when compiling TypeScript code that excludes the test

Our application is built using TypeScript and the source code resides in the /src directory. We have tests located in the /tests directory. When we compile the code locally using TSC, the compiled files are deposited into /dist/src and /dist/test respectiv ...

Processing JSON Serialization from Controller to AJAX Response

I'm struggling to find the correct way to use an HttpWebRequest, and then convert its response into a readable format of JSON for a JavaScript AJAX function. If I just return the raw text, it includes escaping slashes in the response. If I deserializ ...

How to utilize gettext in JavaScript through XMLHttpRequest from PHP

My application is primarily written in PHP with translations handled using gettext(). However, there are also strings in a small JavaScript portion that need to be translated. To address this, I developed a simple method using XMLHttpRequest: function get ...

When using Javascript in a JSP page, it may not always read every element within an array

A project I'm currently working on involves developing a web application that prompts users to input estimated costs for various items. To accomplish this task, I am utilizing a JavaScript function to generate the necessary fields dynamically. var fi ...

Creating a callback in C code with Emscripten for JavaScript integration

In this challenge, the goal is to incorporate a JavaScript function as a callback to display progress during a while-loop operation. For example: var my_js_fn = function(curstate, maxstate){//int variables console.log(curstate.toString() + " of " + maxsta ...

Configuring Access-Control-Allow-Origin does not function properly in AJAX/Node.js interactions

I'm constantly encountering the same issue repeatedly: XMLHttpRequest cannot load http://localhost:3000/form. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefor ...

Tips for choosing an ID in Jquery to use in an if statement

I'm trying to create a form selector that will display different outputs depending on the selected option. However, I'm having some trouble getting it to work. Below is my current code: <!doctype html> <html> <head> <meta ch ...

Is there a way to convert CSV data into an array format?

I am trying to convert a CSV file into an array, but I'm encountering an issue. I have the name of the CSV file, but when I attempt to parse it, I receive the following error message: 'The provided file test.csv doesn't exist or is inaccessi ...

Double trouble: Knockout validation errors displayed twice

Currently, I am using the knockout validation plugin to validate a basic form field. The validation functionality is working as expected, however, it seems to be displaying the same error message twice under the text box. The code snippet that I am using ...

Is there a way to retrieve the index positions of the currently selected rows in Bootstrap Vue's table when implementing range selection?

Here is an example: If I perform a range selection like shown here: https://i.sstatic.net/gc6M8.png The resulting array index list will be: [0, 1, 2] How can I make it show: [0, 1, 3]? In other words, how do I obtain the indices of the currently select ...

Increased accuracy in wildcard regexp usage

I wrote a script that uses wildcards to filter filenames. For example, using `*.js` will give me all the JavaScript files in a directory. However, I encountered an issue where it also includes `.json` files in the results, which is not what I intended. T ...