Mirror: React hooks for accessible, common web interactions. UI super powers without the UI.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Invert priority stack

+5 -5
+5 -5
src/usePriority.ts
··· 10 10 const sortByHierarchy = (a: HTMLElement, b: HTMLElement) => { 11 11 const x = a.compareDocumentPosition(b); 12 12 return ( 13 - (x & 16 /* a contains b */ && -1) || 14 - (x & 8 /* b contains a */ && 1) || 15 - (x & 2 /* b follows a */ && -1) || 16 - (x & 4 /* a follows b */ && 1) || 13 + (x & 16 /* a contains b */ && 1) || 14 + (x & 8 /* b contains a */ && -1) || 15 + (x & 2 /* b follows a */ && 1) || 16 + (x & 4 /* a follows b */ && -1) || 17 17 0 18 18 ); 19 19 }; ··· 26 26 function computeHasPriority(): boolean { 27 27 if (!ref.current) return false; 28 28 const tempStack = priorityStack.concat(ref.current).sort(sortByHierarchy); 29 - return tempStack[tempStack.length - 1] === ref.current; 29 + return tempStack[0] === ref.current; 30 30 } 31 31 32 32 const isDisabled = !!disabled;