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.

custom_fields absolute position not working

See original GitHub issue

Describe the bug Following the documentation on custom_fields here (https://github.com/custom-cards/button-card#custom-fields) together with position: I expect to be able to position a nested card on top of the main card. However, it is positioned adjacent to it.

Version of the card Version: 3.4.1

To Reproduce This is the configuration I used:

entity: lock.haustur
show_name: true
show_state: false
state:
  - value: locked
    entity_picture: /local/images/nuki/nuki_locked_alpha.png
  - value: unlocked
    entity_picture: /local/images/nuki/nuki_unlocked_alpha.png
show_entity_picture: true
tap_action:
  action: call-service
  service: lock.open
  service_data:
    entity_id: lock.haustur
size: 60%
styles:
  card:
    - '--mdc-ripple-color': black
    - '--mdc-press-opacity': 0.5
  grid:
    - position: relative
  custom_fields:
    - position: absolute
    - top: 50%
custom_fields:
  State:
    card:
      type: markdown
      content: '[[[ return entity.state ]]]'
      style: |
        ha-card {
          box-shadow: none;
        }

Screenshots This is the resulting card: 2020-12-28_18-10-56

Expected behavior I would like to see the state locked written in the center of the circle

Desktop (please complete the following information):

  • Browser: Edge
  • Version 87.0.664.66

Smartphone (please complete the following information):

  • Device: Samsung S20
  • OS: Android 11
  • Home Assistant App

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
kongo09commented, Dec 28, 2020

Thanks, adding pointer-events: none indeed does work. I just read in issue #410 that this behaviour is expected but the solution is as simple as it is elegant.

For the benefit of anyone ever reading this, here is my full card code which I use to control a Nuki lock:

type: 'custom:button-card'
entity: lock.wohnung
show_name: true
show_state: false
state:
  - value: locked
    entity_picture: /local/images/nuki/nuki_locked_alpha.png
  - value: unlocked
    entity_picture: /local/images/nuki/nuki_unlocked_alpha.png
tap_action:
  action: call-service
  haptic: medium
  service: script.toggle_nuki_door
  service_data:
    nuki_lock_id: lock.wohnung
double_tap_action:
  action: call-service
  haptic: medium
  service: lock.open
  service_data:
    entity_id: lock.wohnung
show_entity_picture: true
size: 60%
styles:
  card:
    - '--mdc-ripple-color': black
    - '--mdc-press-opacity': 0.5
  grid:
    - position: relative
  custom_fields:
    State:
      - position: absolute
      - top: 50%
      - left: 50%
      - font-size: 80%
      - transform: 'translate(-50%, -60%)'
      - pointer-events: none
custom_fields:
  State:
    card:
      type: markdown
      content: '[[[ return entity.state ]]]'
      style: |
        ha-card {
          box-shadow: none;
          background: none;
        }

As the lock entity doesn’t know any toggle, I call a script depending on state:

alias: Toggle Nuki Door
sequence:
  - choose:
      - conditions:
          - condition: state
            entity_id: lock.wohnung
            state: locked
        sequence:
          - service: lock.unlock
            data: {}
            entity_id: lock.wohnung
      - conditions:
          - condition: state
            entity_id: lock.wohnung
            state: unlocked
        sequence:
          - service: lock.lock
            data: {}
            entity_id: lock.wohnung
    default: []
mode: queued
icon: 'mdi:lock'
max: 3
fields:
  nuki_entity_id:
    description: Entity of Nuki door
    example: lock.wohnung
description: Toggle the open status of a Nuki door

0reactions
RomRidercommented, Dec 28, 2020

You can maybe try by adding pointer-events: none to the style of your custom_field named State. However, what you are having is the expected behavior. A child card will catch the events, thus the the child card action defined in its own config is executed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Absolute position is not working - Stack Overflow
The solution is to apply position:relative to the parent div, which forces it to become a positioned element and the child's offsetParent ....
Read more >
A Guide to Understanding & Using Divi's Absolute Position
The absolute position property is one of four main position types available within Divi and its new position options.
Read more >
CSS-Overflow hidden not working for absolutely positioned ...
In order to have absolute positioned “wrapper img” work with the property of overflow: hidden, position the parent element “wrapper” to ...
Read more >
CSS "absolute" on nested child container required to position it
Problem : I can't seem to position the inner container without assigning a class ... with Toolset for custom field types and complex...
Read more >
Create a Smart Contact Form - Help Scout Support
Add Custom Fields to Beacon on Help Scout Plus. Did this answer your question? Thanks for the feedback There was a problem submitting ......
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