Giter VIP home page Giter VIP logo

Comments (7)

DevFelixDorn avatar DevFelixDorn commented on July 29, 2024

+1 checkbox, radio had the same problem

from matter.

finnhvman avatar finnhvman commented on July 29, 2024

@nevf @DevFelixDorn I see, I'll look into it.

from matter.

nevf avatar nevf commented on July 29, 2024

@finnhvman Thanks. text should be optional for all of these.

from matter.

nevf avatar nevf commented on July 29, 2024

I've got a switch without any text inside an <a> element and see a weird focus? outline when the <a> has focus. I assume this is related to my original issue.

image

from matter.

finnhvman avatar finnhvman commented on July 29, 2024

@nevf @DevFelixDorn The Matter Switch, Radio, and Checkbox components rely on the same html structure, the root cause is basically the same for all these.

As far as I understood it's related to the vertical-align property having the baseline the default value (CSS Spec). The outer-most wrapping element of these controls is the . In case there's text in the label, the baselines of the label and sibling controls are aligned well, if there's no text in the label it gets messed up.

One solution I can suggest is using a Zero-Width Space as text like <span>&#8203;</span>.

The other solution could be me adding vertical-align: middle; to the of these controls, but that would mess up the nice baseline alignment in case of texts.

What are your use cases for these controls without text?


@nevf The weird focus issue is probably the browser figuring out a combined outline of all the children elements of the anchor. In case of the Switch it's the pseudo element used for the ripple that causes the irregularity. You know, the growing and fading blue circle when you switch the switch. I can't really get around this issue, because of the CSS-onliness.

Although, I have to ask, why are you putting a Switch inside of an anchor?

According to HTML Specification it's not permitted (and it's not good UX):

Permitted content | Transparent, containing either flow content (excluding interactive content) or phrasing content.

from matter.

DevFelixDorn avatar DevFelixDorn commented on July 29, 2024

I need only a switch without span when I had a more complex layout which require some complex flexbox/grid. It's happened not really often but it's happened ¯_(ツ)_/¯
I don't put input in anchor elements

from matter.

nevf avatar nevf commented on July 29, 2024

@finnhvman Ben I'm using switch and checkbox in menu and tree items where the text is not part of the switch/checkbox. Further there are areas where I just use an icon + switch/checkbox with no text.

This screen shot shows examples of both:
image
A menu item/row is an <a> with text, links, switch/checkbox inside it. I'll look at revisiting using an anchor for this type of menu item.

Would having two variations of switch/checkbox etc. be the solution, one with the text <span> and one without?

Would the latter resolve my focus issue?

from matter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.