Giter Site home page Giter Site logo

Comments (4)

jfrux avatar jfrux commented on May 28, 2024 1

Wow, actually... just discovered it was the dist/index.min.js that wasn't sorting properly...
Somehow with the dist/index.js its working.

from lrud.

jfrux avatar jfrux commented on May 28, 2024

I take this back... this is still very much a bug.
It MAY be an issue with certain browsers or something...

My app is deployed in FireTV and I put some console logs inside of Lrud.getNodeLastChild() and it looks like this... I did a fresh build after adding console.logs to the index.ts's getNodeLastChild(); like so...

getNodeLastChild(node: Node): Node {
    console.log("getNodeLastChild()");
    if (!node.children) {
      return undefined
    }
    console.log("node.children before sorting",JSON.parse(JSON.stringify(node.children)));
    const orderedIndexes = Object.keys(node.children).map((childId) => {
      const childIndex = node.children[childId].index;
      console.log(`Mapping child ${childId} to ${childIndex}`);
      return childIndex;
    }).sort();
    console.log("orderedIndexes after sorting",JSON.parse(JSON.stringify(orderedIndexes)));
    console.log("lastIndex of orderedIndex:",orderedIndexes.length - 1);
    return _findChildWithIndex(node, orderedIndexes[orderedIndexes.length - 1])
  }

image

So what's happening is... since the last index returns 9... the wrapping nature of the response is always 9.

from lrud.

jfrux avatar jfrux commented on May 28, 2024
const orderedIndexes = Object.keys(node.children).map(childId => node.children[childId].index).sort()

to

const orderedIndexes = Object.keys(node.children).map(childId => node.children[childId].index)

Fixes the problem.

Having that seemingly innocent extra sort() without the callback to tell it how to sort it...

from lrud.

epatrasc avatar epatrasc commented on May 28, 2024

Hi @jfrux ,

Thanks for your investigation, you're right. The sort, without a proper callback, is not sorting the indexes correctly, it's treating number as string.

I'll open a PR to fix the issue.

from lrud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.