question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Popup won't open when inside disabled FormField

See original GitHub issue

My use case is that I use Popup component to display a small information text about fields inside a form. Sometimes those fields are disabled (because the user is not allowed to change them at the moment). That does not mean the information is not valuable to the user. Please fix so that Popup always opens, even though field is disabled.

Field with info enabled_field Disabled field won’t show info disabled_field

Steps

  1. Create info popup inside form field
  2. Disable the field

Expected Result

Popup opens on mouse hover

Actual Result

Popup does not open on mouse hover (when form field is disabled.)

Version

0.66.0

Testcase

The code is very simple (rewrote code from the docs):

import React from 'react'
import { Button, Checkbox, Form, Popup, Icon } from 'semantic-ui-react'

const FormExampleForm = () => (
  <Form>
    <Form.Field disabled>
      <label>First Name <Popup trigger={<Icon name="question" circular size="small" inverted/>} content="Some info here" /> </label>
      <input placeholder='First Name' disabled/>
    </Form.Field>
    <Button type='submit'>Submit</Button>
  </Form>
)

export default FormExampleForm

Thank you for an amazing library!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
bthjcommented, May 20, 2018

The workaround is to place the Popup in the tree so that its parent is not disabled.

To achieve this I just wrapped the button in a <span>, like so:

                <Popup
                  trigger={
                    <span>
                      <Button icon='save' content='Save'
                        disabled={true}
                      />
                    </span>
                  }
                  content="popup text..."
                />
0reactions
brianespinosacommented, Jul 12, 2021

Closing as the suggestion to change the disabling of pointer events will resolve the issue if anyone wants to do override what is default in specific cases. I would not recommend adding a <span /> as this will in a number of ways break the CSS due to how SUI class names are built for specificity with specific markup and direct child selectors.

// This has to happen in actual CSS  or a CSS in JS solution because React does not support using !important in style props
// Shown as SCSS for brevity
.withPointerEvents {
  &.ui.button:disabled, 
  &.ui.buttons .disabled.button, 
  &.ui.disabled.active.button, 
  &.ui.disabled.button, 
  &.ui.disabled.button:hover {
    pointer-events: auto !important; // This has to be done in order to override the !important declaration in SUI CSS
}

// In JSX
<Popup 
  content='Add users to your feed' 
  trigger={
    <Button 
      className='withPointerEvents' 
      disabled 
      icon='add' 
    />
  } 
/>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Clicking a disabled input or button - javascript - Stack Overflow
Any event that starts at the disabled form field is completely canceled and does not propagate up the DOM tree. Correct me if...
Read more >
How to disable or enable buttons using Javascript and jQuery
Learn how to enable or disable buttons using javascript and jQuery based on whether the input field is filled or empty.
Read more >
Pop-ups do not display the attribute information in ArcGIS Pro
Display the Fields element in the feature pop-up. Open the ArcGIS Pro project, and click any feature on the map to display the...
Read more >
Forms - Bootstrap
Disabled checkboxes and radios are supported. The disabled attribute will apply a lighter color to help indicate the input's state. Checkboxes and radio...
Read more >
Creating a promotional pop-up - Squarespace Help Center
Trigger a new subscribers form, share a discount, ... You can't have a pop-up on pages within a member area, or on Index...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found