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.

[Android] position: absolute shouldn't be cut off within a container with border

See original GitHub issue

Description

If you have an element position: absolute with negative offset within a container with a border, it’s going to be cut off, it’s like overflow: hidden of the container is suddenly enabled by the border. But if you remove the border of the container, it works well. This issue only happens on Android.

#3198 is a similar issue, and was reported with lots of discussions. However, I believe they are not exactly the same.

Reproduction

I’ve made an example on rnplay to reproduce the issue.

Solution

TBD

Additional Information

  • React Native version: 0.33 (rnplay), 0.39 (the version I currently use)
  • Platform: Android
  • Operating System: MacOS

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:91
  • Comments:63 (5 by maintainers)

github_iconTop GitHub Comments

45reactions
designorantcommented, Nov 28, 2017

Workaround

Use an extra container and fake the overflow with it: https://snack.expo.io/@designorant/overflow-visible-android-workaround

import React, { Component } from "react";
import { View, Text, StyleSheet } from "react-native";

export default class App extends Component {
  render() {
    return (
      <View style={styles.mainContainer}>

        <View style={styles.componentContainer}>
          <View style={[styles.element, styles.element1]} />
          <Text style={styles.text}>overflow: "visible"</Text>
        </View>

        <View style={styles.extraComponentContainer}>
          <View style={[styles.element, styles.element2]} />
          <View style={styles.componentContainer}>
            <Text style={styles.text}>extra container workaround</Text>
          </View>
        </View>

      </View>
    );
  }
}

const styles = StyleSheet.create({
  mainContainer: {
    flex: 1,
    alignItems: "center",
    justifyContent: "space-around"
  },
  componentContainer: {
    backgroundColor: "#d3d3d3",
    borderWidth: 1,
    borderColor: "grey",
    width: 200,
    height: 200,
    position: "relative",
    overflow: "visible" // doesn't do anything
  },
  extraComponentContainer: {
    // fakes overflow but requires more markup
    backgroundColor: "#ffff00",
    paddingTop: 20,
    paddingLeft: 20,
    paddingBottom: 20,
    paddingRight: 20,
    position: "relative"
  },
  element: {
    backgroundColor: "#ff0000",
    width: 40,
    height: 40
  },
  element1: {
    position: "absolute",
    top: -20,
    left: -20
  },
  element2: {
    position: "absolute",
    top: 0,
    left: 0,
    zIndex: 100,
    elevation: 100
  },
  text: {
    textAlign: "right",
    backgroundColor: "transparent"
  }
});

overflowvisible

33reactions
scottwiocommented, Aug 9, 2018

Still an issue 😭

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android position: absolute shouldn't be cut off within a ...
Here is my code which will better understand you guys. //Confirm Popup component import React from 'react'; import { Modal ...
Read more >
absolute shouldn't be cut off within a container with border ...
Coding example for the question Android position: absolute shouldn't be cut off within a container with border-React Native.
Read more >
border-left - CSS: Cascading Style Sheets - MDN Web Docs
The border-left shorthand CSS property sets all the properties of an element's left border.
Read more >
LinearLayout | Android Developers
LayoutParams to learn about other attributes you can set on a child view to affect its position and size in the containing linear...
Read more >
Safari Technology Preview Release Notes - Apple Developer
Fixed inline box decoration position when the content box is vertically shifted ... positioning of position: absolute items within nested grids (r290674) ...
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