Skip to content

Commit

Permalink
Merge pull request #36 from pinterest/protodave/fix-filtering-order
Browse files Browse the repository at this point in the history
Bug: Fix node filtering order
  • Loading branch information
protodave authored Dec 20, 2024
2 parents e76119c + a47bf4a commit 8ef1973
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/utils/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,29 +109,25 @@ export function getProcessedNodes(
processedNodes.push(node);
};

// find all the nodes in the document
// Find all the nodes in the document
const allNodes = FigmaDocumentParser.FindAll(rootNode, (n) => true);

let nonHiddenNonIgnoredNodes: BaseNode[] = [];

// toss any hidden nodes, get the counts
const { nonHiddenNodes, numHiddenLayers } =
FigmaCalculator.filterHiddenNodes(allNodes);
nonHiddenNonIgnoredNodes = nonHiddenNodes;

// toss any ignored component nodes
let nonIgnoredNodes: BaseNode[];
// Filter out any ignored component instance nodes first
let nonIgnoredNodes: BaseNode[] = allNodes;
let numIgnoredLayers: number = 0;
if (opts?.ignoredComponentKeys?.length) {
({ nonIgnoredNodes, numIgnoredLayers } =
FigmaCalculator.filterIgnoredComponentNodes(
nonHiddenNodes,
opts?.ignoredComponentKeys
));

nonHiddenNonIgnoredNodes = nonIgnoredNodes;
({ nonIgnoredNodes, numIgnoredLayers } = FigmaCalculator.filterIgnoredComponentNodes(
allNodes,
opts.ignoredComponentKeys
));
}

// Filter any hidden nodes, get the count of hidden layers
const { nonHiddenNodes, numHiddenLayers } = FigmaCalculator.filterHiddenNodes(nonIgnoredNodes);
nonHiddenNonIgnoredNodes = nonHiddenNodes;

// toss any library nodes from the list
const { nonLibraryNodes, numLibraryNodes, libraryNodes } =
FigmaCalculator.filterLibraryNodes(nonHiddenNonIgnoredNodes, {
Expand Down

0 comments on commit 8ef1973

Please sign in to comment.