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

Unable to include tooltips or signposts next to labels in several form fields #271

Open
2 of 7 tasks
jessie-james opened this issue Aug 5, 2022 · 8 comments
Open
2 of 7 tasks
Assignees
Labels
flag:stale workaround Workaround provided

Comments

@jessie-james
Copy link

Describe the bug

Clarity form control containers / fields such as: clr-input, clr-select, clr-combobox, clr-password etc. do not allow for a signpost to be added after the label.

Our forms can be complex we use this to offer more detailed information on a field that is too long for helper text. To get the visual UX we have to embed the signpost or tooltip within the label markup for a field. This causes accessibility screen readers issues. Other work arounds/ solutions are to put the signpost outside the control/ container entirely causing other problems with UX design and rewrite/ overriding css.

How to reproduce

Expected behavior

Developers should be able to add a signpost to any Cl form input/ field after the label.

Versions

Clarity version:

  • v12.x
  • v13.0
  • Other:

Framework:

  • Angular
  • React
  • Vue
  • Other:

Framework version:
_ie: Angular 13.3.0

Device:

  • Type: [ MacBook]
  • OS: [iOS]
  • Browser [e.g. chrome, safari]

Additional notes

@smsalisbury
Copy link

We're also having this issue. Can confirm that the following worked in v12 but doesn't in v13:

<clr-combobox-container>
  <label>
    Form label
    <clr-signpost>
      <div clrSignpostTrigger>Trigger</div>
      <clr-signpost-content *clrIfOpen>
        Signpost content
      </clr-signpost-content>
    </clr-signpost>
  </label>
  <clr-combobox formControlName='comboControl'>
    ...
  </clr-combobox>
</clr-combobox-container>

@kevinbuhmann
Copy link
Member

Internal issue: https://jira.eng.vmware.com/browse/VPAT-12188

@smsalisbury
Copy link

I was able to find a work around to this by making sure that the clrSignpostTrigger is a button. Not ideal since it requires some styling workarounds, but it works for now.

<clr-combobox-container>
  <label>
    Form label
    <clr-signpost>
      <button clrSignpostTrigger>Trigger</button> <!-- This works if it is a button -->
      <clr-signpost-content *clrIfOpen>
        Signpost content
      </clr-signpost-content>
    </clr-signpost>
  </label>
  <clr-combobox formControlName='comboControl'>
    ...
  </clr-combobox>
</clr-combobox-container>

@kevinbuhmann
Copy link
Member

kevinbuhmann commented Nov 16, 2022

The clrSignpostTrigger should be a button, not a div, because it is a clickable/interactive element.

@kevinbuhmann
Copy link
Member

Not ideal since it requires some styling workarounds, but it works for now.

Sorry, I missed this part. I will reopen.

@kevinbuhmann kevinbuhmann reopened this Nov 16, 2022
@kevinbuhmann kevinbuhmann added workaround Workaround provided and removed closed:not a bug labels Nov 16, 2022
@smsalisbury
Copy link

smsalisbury commented Nov 16, 2022

The clrSignpostTrigger should be a button, not a div, because it is a clickable/interactive element.

This makes sense semantically. I see now in the documentation that the examples only use button tags, although the requirement that clrSignpostTrigger be a button is not explicitly called out in the documentation. I guess I was just confused because other tags worked in previous versions.

For styling, it also makes sense that the trigger is usually styled like a Clarity button (e.g. <button class="btn btn-link btn-icon">). But that kind of styling doesn't quite fit in a form control label with the padding and margins that buttons come with. For my use, I simply stripped out the padding/margins on the button and changed the color, but I don't know if that's the right solution in all cases.

@Jinnie
Copy link
Contributor

Jinnie commented Nov 23, 2022

Using button or a elements is just the safest way.

Here you can see the selectors of what do we consider actionable elements.
A div with tabindex=0 is okay too, though you will still need to add role=button.

@kumar-tadepalli
Copy link

I was able to find a work around to this by making sure that the clrSignpostTrigger is a button. Not ideal since it requires some styling workarounds, but it works for now.

<clr-combobox-container>
  <label>
    Form label
    <clr-signpost>
      <button clrSignpostTrigger>Trigger</button> <!-- This works if it is a button -->
      <clr-signpost-content *clrIfOpen>
        Signpost content
      </clr-signpost-content>
    </clr-signpost>
  </label>
  <clr-combobox formControlName='comboControl'>
    ...
  </clr-combobox>
</clr-combobox-container>

We cannot use info cds-icon with this workaround right?

@dtsanevmw dtsanevmw self-assigned this Sep 7, 2023
dtsanevmw added a commit that referenced this issue Jan 7, 2025
## PR Checklist

Please check if your PR fulfills the following requirements:

- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)
- [ ] If applicable, have a visual design approval

## PR Type

What kind of change does this PR introduce?

<!-- Please check the one that applies to this PR using "x". -->

- [X] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Documentation content changes
- [ ] Other... Please describe:

## What is the current behavior?

Currently if you put signposts inside labels they are not working due to
that `<label>` be default is spreading a click event to its children and
that's causing the signpost to automatically close and not appear.
**Example:**
If you have a label attached to an input or input inside a label and
click the label - the input will get focused.

Issue Number: CDE-9 and #271 

## What is the new behavior?

Signposts are now working inside `<label>`.

## Does this PR introduce a breaking change?

- [ ] Yes
- [X] No

<!-- If this PR contains a breaking change, please describe the impact
and migration path for existing applications below. -->

## Other information

---------

Co-authored-by: Kevin Buhmann <kbuhmann@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flag:stale workaround Workaround provided
Projects
None yet
Development

No branches or pull requests

6 participants