Attempting to render a container within a hidden div and then make it visible results in an error

There appears to be an issue with ExtJS 6 regarding a bug. The problem can be replicated with minimal code in this online demo. In the code snippet below, we have a hidden div:

<div id="btn"></div>
<div style="display:none" id="outer_container">
    <div id="test_container"></div>
</div>

We are rendering a Button to the btn div and a Component to the test_container as shown:

var id = Ext.id();
Ext.create("Ext.Button",{
    text: "show",
    renderTo: "btn",
    handler: function (){
        document.getElementById("outer_container").style.display = "block";
        //Ext.getCmp(id).setVisible(true) // does not help
    }
});
Ext.create("Ext.container.Container", {
    renderTo: "test_container",
    width:"400",
    border:"1",
    id: id,
    style:{
        borderColor:"#000000",
        borderStyle:"solid",
        borderWidth:"1px"
    },
    layout:{type:"hbox"},
    defaults:{labelWidth:"80"},
    items:[
        {"xtype":"numberfield", "name":"attr_1_"},{"xtype":"datefield","startDay":"1","format":"d.m.Y","name":"attr_2_"}
    ]
});

Upon clicking the button to display our component, only a gray line is visible and upon inspecting the DOM, it shows that the component has zero height and width. How should this issue be addressed?

Answer №1

If you are not obligated to utilize Ext.container.Container, consider using Ext.panel.Panel. The panel component appears to apply style information correctly after the updateLayout function is called.

However, make sure to update the layout in your handler after clicking the button.

var id = Ext.id();
        Ext.create("Ext.Button",{
            text: "show",
            renderTo: "btn",
            handler: function (){
                document.getElementById("outer_container").style.display = "block";
                Ext.getCmp(id).updateLayout();
            }
        });
        Ext.create("Ext.Panel", {
            renderTo: "test_container",
            width:400,
            visible:true,
            id : id,
            border:"1",
            style:{
                borderColor:"#000000",
                borderStyle:"solid",
                borderWidth:"1px"
            },
            layout:{type:"hbox"},
            defaults:{labelWidth:"80"},
            items:[
                {"xtype":"numberfield", "name":"attr_1_"},
                {"xtype":"datefield","startDay":"1","format":"d.m.Y","name":"attr_2_"}
            ]
        });

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using Node.js and Less to dynamically select a stylesheet source depending on the subdomain

Currently, my tech stack consists of nodejs, express, jade, and less. I have set up routing to different subdomains (for example: college1.domain.com, college2.domain.com). Each college has its own unique stylesheet. I am looking for a way to selectively ...

Array in Javascript reset to null after its second iteration

''' const users = [] const addUser = ({ id, username, room }) => { // Clean the data username = username.trim().toLowerCase() room = room.trim().toLowerCase() // Validate the data if (!username || !room) { r ...

How do I utilize ng-repeat in Angular to pass a variable that specifies the number of repetitions?

When working on my app, I encountered a situation where I needed to retrieve elements from a database and display them using ng-reat. Everything was going smoothly until I realized that within this list, there was another set of data that required a separa ...

I am looking to implement an animation that automatically scrolls to the bottom of a scrollable DIV when the page is loaded

My DIV is configured with overflow-y set to scroll. .scrolling-div { width: 85%; height: 200px; overflow-y: scroll; } If I have an abundance of content within this div, my goal is for it to automatically scroll to the bottom upon loading the page. I am ...

Issues encountered when implementing server-sent events in a project built with Node.js and React

I've been working on implementing server-sent-events into my Node.js and React application. After doing some research and following tutorials online, I found this particular site to be very helpful and straightforward. The main objective is to have a ...

trouble with fetching data

Within my Backbone view, I have the following code snippet: var BookView = Backbone.View.extend({ initialize: function() { this.render(); }, render: function() { this.model.fetch({ success : function(model, resp, opt) { alert(this.$el. ...

Delay in Updating Nativescript Slider Value

After developing a metronome using the Nativescript Slider here to adjust speed (interval), I encountered an issue with incorrect updating of values. The code initially worked well, allowing real-time speed changes: app.component.html <Slider #sl min ...

How can I link two separate webpages upon submitting a form with a single click?

Here is a snippet of my code: <form action="register.php" method="post"> <input type="text" name="uname"> <input type="submit" > </form> Within the register.php file, there are codes for connecting to a database. I am looking ...

React - Component not updating after Axios call in separate file

Recently I decided to delve into React while working on some R&D projects. One of my goals was to build an application from scratch as a way to learn and practice with the framework. As I started working on my project, I encountered a rather perplexin ...

Issues encountered - nodejs-lts (exit code 1603) - Problem occurred during execution of 'C:ProgramDatachocolateylib odejs-lts oolschocolateyinstall.ps1' script

Encountering Issues with Installing 64-bit Version of nodejs-lts... Received a Generic MSI Error during installation, indicating a local environment issue rather than a problem with the package or MSI file itself. Possible reasons for thi ...

Manipulate sibling elements using jQuery's addClass and remove methods

I have implemented a function that adds the class active to elements when they reach the top of the browser, ensuring that the next element will scroll in over the top. While this works smoothly in Chrome, I am encountering some jumping behavior when testi ...

handle an exception within the initializer of its object

I'm currently working with an Ajax object that is utilized in various other objects to load 'Json' files. One issue I'm facing is trying to catch the 404 'Not found' exception thrown in the initializer object. However, every ...

Looking to confirm client-side text in NodeJS?

As I work on constructing a to-do list, one challenge I am encountering is confirming that the correct task has been checked off. While considering using unique IDs for each individual task may seem like a solution, there is still the risk of users manipul ...

React Express Error: Unable to access property 'then' of undefined

I'm facing an issue while trying to server-side render my react app for users who have disabled JavaScript and also for better search engine optimization. However, I am encountering the following error: TypeError: Cannot read property 'then' ...

Obtain the key's value from a JSON object that is nested within another

Managing a complex data structure is crucial in programming. How can I efficiently retrieve specific values using known keys from this nested data? Take, for instance: var data = { code: 42, items: [{ id: 1, category: [{ ...

Fetching data using ajax and then appending it to the webpage

I am currently loading content from a PHP file in JSON format. products.php <?php $stmt = $mysqli->prepare("SELECT * FROM products LIMIT 10"); $stmt->execute(); $products = $stmt->get_result(); $produc ...

Avoid running the second then() function in a promise if a specific condition is satisfied

Can anyone help me figure out how to prevent the code block below from executing any further once arkIsEnabled is evaluated as true? return promise .then(response => { if (arkIsEnabled) { dispatch(createArk(respo ...

How to automatically refresh a page in AngularJS after a POST request

After making a POST request, I attempted to use $state.reload in my controller to refresh the page. However, it is not updating the data on my page after registering the form. I have to manually refresh the page to see the correct data. .controller(' ...

When working with THREE.js in Electron, web development tools seem to vanish into thin air

Exploring electron is fairly new to me (if you know of any good documentation, please leave it in the comments) and I've encountered an issue that has left me puzzled: Everything seems fine until I load the THREE.js library. At that point, even thoug ...

`A dynamically captivating banner featuring animated visuals created with JQuery`

I am currently in the process of designing a banner for the top of my webpage, but I have yet to come across any code that meets all my requirements. To provide clarification, I have attached an illustration showcasing what I am aiming to achieve. 1) The ...