Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The 'icon' prop of q-advatar set 'none' is not work #17296

Closed
Summeryuan opened this issue Jun 19, 2024 · 1 comment
Closed

The 'icon' prop of q-advatar set 'none' is not work #17296

Summeryuan opened this issue Jun 19, 2024 · 1 comment
Labels
area/components bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/quasar-cli-vite kind/bug 🐞 Qv2 🔝 Quasar v2 issues

Comments

@Summeryuan
Copy link

Summeryuan commented Jun 19, 2024

What happened?

The component q-avatar has a prop 'icon', as the docs:

Icon name following Quasar convention....... If 'none' (String) is used as value then no icon is rendered (but screen real estate will still be used for it). from webpage: https://quasar.dev/vue-components/avatar

But in my test, the value of icon prop was set 'none'(String) is not work, the DOM was still rendered as an <i> tag:

<i class="q-icon" aria-hidden="true" role="presentation"></i>

Instead of that, I set the icon prop as 'undefined'( javascript literal, not String, it is work!!!

CODE:
This code will render an <i> tag and an <img> in the Avatar Div:

<q-avatar :icon="userAvatar ? 'none' : 'add_a_photo'" cursor-pointer @click="changeAvatar" > <img v-if="userAvatar" :src="userAvatar" /> </q-avatar>

This code will render just an single <img> in the Avatar Div:
<q-avatar :icon="userAvatar ? undefined : 'add_a_photo'" cursor-pointer @click="changeAvatar" > <img v-if="userAvatar" :src="userAvatar" /> </q-avatar>

What did you expect to happen?

In my opinion, the literal 'undefined' is not a common use, the String 'none' is better.

Reproduction URL

https://codepen.io/Summeryuan/pen/pomaZEV

How to reproduce?

  1. Create a Quasar project
  2. Create a Vue Component
  3. In the 'template' segment, add a q-avatar component ,and set the icon prop value as 'none'

Flavour

Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)

Areas

Components (quasar)

Platforms/Browsers

Microsoft Edge

Quasar info output

Operating System - Windows_NT(10.0.22631) - win32/x64
NodeJs - 16.17.1

Global packages
  NPM - 8.15.0
  yarn - Not installed
  @quasar/cli - 2.4.1
  @quasar/icongenie - Not installed
  cordova - Not installed

Important local packages
  quasar - 2.16.4 -- Build high-performance VueJS user interfaces (SPA, PWA, SSR, Mobile and Desktop) in record time
  @quasar/app-vite - 1.9.3 -- Quasar Framework App CLI with Vite
  @quasar/extras - 1.16.11 -- Quasar Framework fonts, icons and animations
  eslint-plugin-quasar - Not installed
  vue - 3.4.27 -- The progressive JavaScript framework for building modern web UI.
  vue-router - 4.3.2
  pinia - 2.1.7 -- Intuitive, type safe and flexible Store for Vue
  vuex - Not installed
  vite - 2.9.18 -- Native-ESM powered web dev build tool
  eslint - 8.57.0 -- An AST-based pattern checker for JavaScript.
  electron - Not installed
  electron-packager - Not installed
  @electron/packager - Not installed
  electron-builder - Not installed
  register-service-worker - 1.7.2 -- Script for registering service worker, with hooks
  @capacitor/core - Not installed
  @capacitor/cli - Not installed
  @capacitor/android - Not installed
  @capacitor/ios - Not installed

Quasar App Extensions
  *None installed*

Networking
  Host - Sus_PC
  以太网 - 192.168.1.9

Relevant log output

None

Additional context

None

@github-actions github-actions bot added area/components bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/quasar-cli-vite labels Jun 19, 2024
@yusufkandemir
Copy link
Member

It's the expected behavior as you also shared, as stated in the docs:

If 'none' (String) is used as value then no icon is rendered (but screen real estate will still be used for it)

When you use 'none', it renders the <i> tag without any content. So, it would take space in the screen, but not have anything visible in it, as stated in the docs.

When you use undefined, it doesn't even render <i>, so it will not have any visible content and will not occupy space either.

So, using 'none' or undefined depends on your aim. Both are valid options with different behavior.

@yusufkandemir yusufkandemir closed this as not planned Won't fix, can't repro, duplicate, stale Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/components bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/quasar-cli-vite kind/bug 🐞 Qv2 🔝 Quasar v2 issues
Projects
None yet
Development

No branches or pull requests

2 participants