robcresswell / vue-material-design-icons

Material Design Icons as Vue Single File Components
https://npmjs.com/vue-material-design-icons
MIT License
162 stars 35 forks source link

Title conflicts #115

Closed krmax44 closed 2 years ago

krmax44 commented 4 years ago

Let's look at the following snippet:

<button title="My title">
  <settings-icon />
</button>

What happens once the user hovers over the button is that the default icon overrides the button title. The current workarounds are

<button title="Open settings">
  <settings-icon title="Open settings" /> <!-- oof, very repetetive, or -->
  <settings-icon :title="false" /> <--! oof, very strange -->
</button>

...both aren't that great. Two alternative ways would be:

robcresswell commented 4 years ago

I'm very reluctant to start adding "magic" implicit titles over explicit ones, given you can assign the title to a variable in Vue to avoid the horrors of repetition. What do you imagine this would look like in code?

gambolputty commented 4 years ago

I stumbled upon a similar problem. The code rendered by Chrome is the following:

<button title="Outline" class="sidebar__tab">
  <span aria-label="Pound icon" role="img" class="material-design-icon pound-icon">
    <svg fill="currentColor" width="28" height="28" viewBox="0 0 24 24" class="material-design-icon__svg">
      <path d="...">
        <title>Pound icon</title>
      </path>
    </svg>
  </span>
</button>

This is just a button with an icon. When hovering with the mouse, the title changes: sometimes it's "Outline" (triggered by button atrribute) and sometimes "Pound icon" (triggered by element inside svg). I could not find a way to change that behavior. Could you help?</p> <p>Btw: thanks for making this project :)</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/gambolputty"><img src="https://avatars.githubusercontent.com/u/8270488?v=4" />gambolputty</a> commented <strong> 4 years ago</strong> </div> <div class="markdown-body"> <p>Additionally: if I don't set a title to the wrapping element, "Pound icon" is still displayed and not very informative. I wish there was a way to disable these titles. </p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/gambolputty"><img src="https://avatars.githubusercontent.com/u/8270488?v=4" />gambolputty</a> commented <strong> 4 years ago</strong> </div> <div class="markdown-body"> <p>I fixed this myself by setting <code>pointer-events: none</code> inside the CSS class <code>.material-design-icon</code> (I'm using custom CSS)</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/krmax44"><img src="https://avatars.githubusercontent.com/u/12673799?v=4" />krmax44</a> commented <strong> 4 years ago</strong> </div> <div class="markdown-body"> <p>That's a clever workaround, but bears some accessibility problems, unfortunately.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/robcresswell"><img src="https://avatars.githubusercontent.com/u/3816327?v=4" />robcresswell</a> commented <strong> 4 years ago</strong> </div> <div class="markdown-body"> <p>I can see how this is annoying... any suggestions of what this may look like in code? I was generally trying to balance a11y / performance against niceties in computed properties etc when designing this.</p> <p>Would making the title <code><title>{{ props.title }}</title></code> conditional based on <code>decorative</code> solve this? i.e. <code><title v-if="!decorative">{{ props.title }}</title></code></p> <p>Unfortunately I've not done any frontend work for almost 2 years now; I mostly just keep this updated because the maintenance cost is low and people seem to be using it :smile: </p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/bradley-varol"><img src="https://avatars.githubusercontent.com/u/19194140?v=4" />bradley-varol</a> commented <strong> 4 years ago</strong> </div> <div class="markdown-body"> <p>I'd really like to be able to disable this. I've got buttons with titles containing icons and on icon hover, the title is wrong.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/robcresswell"><img src="https://avatars.githubusercontent.com/u/3816327?v=4" />robcresswell</a> commented <strong> 4 years ago</strong> </div> <div class="markdown-body"> <p>@bradley-varol If you've a suggestion on what you'd prefer, please make it :smile: I have made a suggestion above, but nobody has replied. I don't use Vue much nowadays, so I don't have much drive to spend a weekend investigating fixes.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/robcresswell"><img src="https://avatars.githubusercontent.com/u/3816327?v=4" />robcresswell</a> commented <strong> 3 years ago</strong> </div> <div class="markdown-body"> <p>@bradley-varol @krmax44 @gambolputty Does the linked PR solve your problem?</p> <p>As I've stated before, I don't do much Vue nowadays, but I'm happy to keep maintaining this. Would appreciate some others eyes on the PR though 😃 </p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/robcresswell"><img src="https://avatars.githubusercontent.com/u/3816327?v=4" />robcresswell</a> commented <strong> 2 years ago</strong> </div> <div class="markdown-body"> <p>I'm going to close this; I've changed how titles work as of <a href="https://github.com/robcresswell/vue-material-design-icons/releases/tag/5.0.0"><code>5.0.0</code></a> and there hasn't been much activity</p> </div> </div> <div class="page-bar-simple"> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>