Results 1 to 3 of 3

Thread: Modern: Component margins don't respect non-px units in string form

    You found a bug! We've classified it as EXTJS-27510 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,257

    Default Modern: Component margins don't respect non-px units in string form

    Fiddle: https://fiddle.sencha.com/#view/editor&fiddle/2l74

    Observe in the first component, we use:

    Code:
    margin: '5em'
    This ends up generating a 5px margin. If the object form is passed, it doesn't attempt to parse the value out. The issue lies at the end of parseBox where it tries to parseFloat() the value without checking a unit exists.

    A potential fix could be something like:

    Code:
    const E = Ext.dom.Element;
    const getBoxPart = v => E.hasUnit(v) ? v : (parseFloat(v) || 0);
    
    E.parseBox = (box) => {
        box = box || 0;
    
        const type = typeof box;
    
        if (type === 'number') {
            return {
                top: box,
                right: box,
                bottom: box,
                left: box
            };
        } else if (type !== 'string') {
            // If not a number or a string, assume we've been given a box config.
            return box;
        }
    
        const parts  = box.split(' ');
        const ln = parts.length;
    
        if (ln === 1) {
            parts[1] = parts[2] = parts[3] = parts[0];
        } else if (ln === 2) {
            parts[2] = parts[0];
            parts[3] = parts[1];
        } else if (ln === 3) {
            parts[3] = parts[1];
        }
    
        return {
            top: getBoxPart(parts[0]),
            right: getBoxPart(parts[1]),
            bottom: getBoxPart(parts[2]),
            left: getBoxPart(parts[3])
        };
    };
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  2. #2
    Sencha - Forum Administrator
    Join Date
    Sep 2017
    Posts
    1,005

    Default

    Thank you Evan. I'll send this over to the support team right away.

  3. #3
    Sencha Staff
    Join Date
    Sep 2017
    Posts
    126

    Default

    Thanks for the report! I have opened a bug in our bug tracker.

Similar Threads

  1. Replies: 4
    Last Post: 25 May 2018, 1:01 AM
  2. Replies: 3
    Last Post: 2 Dec 2012, 8:23 PM
  3. [2.x] Units (aka:right label) in a form panel
    By elnove in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 20 Aug 2008, 7:58 AM
  4. Collapsed layout region don't respect 'margins' config property.
    By MaximGB in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 31 Jul 2007, 4:54 PM
  5. Replies: 0
    Last Post: 31 Jul 2007, 4:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •