Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Fix node filtering order #36

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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