Skip to content

Commit 6ea2095

Browse files
committed
[DevTools] Don't select on hover (facebook#34860)
We should only persist a selection once you click. Currently, we persist the selection if you just hover which means you lose your selection immediately when just starting to inspect. That's not what Chrome Elements tab does - it selects on click. DiffTrain build for [903366b](facebook@903366b)
1 parent 05c9bf1 commit 6ea2095

35 files changed

+137
-151
lines changed

compiled/eslint-plugin-react-hooks/index.js

Lines changed: 51 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -37178,49 +37178,30 @@ function memoizeFbtAndMacroOperandsInSameScope(fn) {
3717837178
...Array.from(FBT_TAGS).map((tag) => [tag, []]),
3717937179
...((_a = fn.env.config.customMacros) !== null && _a !== void 0 ? _a : []),
3718037180
]);
37181-
const macroTagsCalls = new Set();
37182-
const macroValues = new Map();
37181+
const fbtValues = new Set();
3718337182
const macroMethods = new Map();
37184-
visit$1(fn, fbtMacroTags, macroTagsCalls, macroMethods, macroValues);
37185-
for (const root of macroValues.keys()) {
37186-
const scope = root.scope;
37187-
if (scope == null) {
37188-
continue;
37189-
}
37190-
if (!macroTagsCalls.has(root.id)) {
37191-
continue;
37183+
while (true) {
37184+
let vsize = fbtValues.size;
37185+
let msize = macroMethods.size;
37186+
visit$1(fn, fbtMacroTags, fbtValues, macroMethods);
37187+
if (vsize === fbtValues.size && msize === macroMethods.size) {
37188+
break;
3719237189
}
37193-
mergeScopes(root, scope, macroValues, macroTagsCalls);
3719437190
}
37195-
return macroTagsCalls;
37191+
return fbtValues;
3719637192
}
3719737193
const FBT_TAGS = new Set([
3719837194
'fbt',
3719937195
'fbt:param',
37200-
'fbt:enum',
37201-
'fbt:plural',
3720237196
'fbs',
3720337197
'fbs:param',
37204-
'fbs:enum',
37205-
'fbs:plural',
3720637198
]);
3720737199
const SINGLE_CHILD_FBT_TAGS = new Set([
3720837200
'fbt:param',
3720937201
'fbs:param',
3721037202
]);
37211-
function visit$1(fn, fbtMacroTags, macroTagsCalls, macroMethods, macroValues) {
37203+
function visit$1(fn, fbtMacroTags, fbtValues, macroMethods) {
3721237204
for (const [, block] of fn.body.blocks) {
37213-
for (const phi of block.phis) {
37214-
const macroOperands = [];
37215-
for (const operand of phi.operands.values()) {
37216-
if (macroValues.has(operand.identifier)) {
37217-
macroOperands.push(operand.identifier);
37218-
}
37219-
}
37220-
if (macroOperands.length !== 0) {
37221-
macroValues.set(phi.place.identifier, macroOperands);
37222-
}
37223-
}
3722437205
for (const instruction of block.instructions) {
3722537206
const { lvalue, value } = instruction;
3722637207
if (lvalue === null) {
@@ -37229,11 +37210,11 @@ function visit$1(fn, fbtMacroTags, macroTagsCalls, macroMethods, macroValues) {
3722937210
if (value.kind === 'Primitive' &&
3723037211
typeof value.value === 'string' &&
3723137212
matchesExactTag(value.value, fbtMacroTags)) {
37232-
macroTagsCalls.add(lvalue.identifier.id);
37213+
fbtValues.add(lvalue.identifier.id);
3723337214
}
3723437215
else if (value.kind === 'LoadGlobal' &&
3723537216
matchesExactTag(value.binding.name, fbtMacroTags)) {
37236-
macroTagsCalls.add(lvalue.identifier.id);
37217+
fbtValues.add(lvalue.identifier.id);
3723737218
}
3723837219
else if (value.kind === 'LoadGlobal' &&
3723937220
matchTagRoot(value.binding.name, fbtMacroTags) !== null) {
@@ -37252,48 +37233,54 @@ function visit$1(fn, fbtMacroTags, macroTagsCalls, macroMethods, macroValues) {
3725237233
newMethods.push(method.slice(1));
3725337234
}
3725437235
else {
37255-
macroTagsCalls.add(lvalue.identifier.id);
37236+
fbtValues.add(lvalue.identifier.id);
3725637237
}
3725737238
}
3725837239
}
3725937240
if (newMethods.length > 0) {
3726037241
macroMethods.set(lvalue.identifier.id, newMethods);
3726137242
}
3726237243
}
37263-
else if (value.kind === 'PropertyLoad' &&
37264-
macroTagsCalls.has(value.object.identifier.id)) {
37265-
macroTagsCalls.add(lvalue.identifier.id);
37244+
else if (isFbtCallExpression(fbtValues, value)) {
37245+
const fbtScope = lvalue.identifier.scope;
37246+
if (fbtScope === null) {
37247+
continue;
37248+
}
37249+
for (const operand of eachReactiveValueOperand(value)) {
37250+
operand.identifier.scope = fbtScope;
37251+
expandFbtScopeRange(fbtScope.range, operand.identifier.mutableRange);
37252+
fbtValues.add(operand.identifier.id);
37253+
}
3726637254
}
37267-
else if (isFbtJsxExpression(fbtMacroTags, macroTagsCalls, value) ||
37268-
isFbtJsxChild(macroTagsCalls, lvalue, value) ||
37269-
isFbtCallExpression(macroTagsCalls, value)) {
37270-
macroTagsCalls.add(lvalue.identifier.id);
37271-
macroValues.set(lvalue.identifier, Array.from(eachInstructionValueOperand(value), operand => operand.identifier));
37255+
else if (isFbtJsxExpression(fbtMacroTags, fbtValues, value) ||
37256+
isFbtJsxChild(fbtValues, lvalue, value)) {
37257+
const fbtScope = lvalue.identifier.scope;
37258+
if (fbtScope === null) {
37259+
continue;
37260+
}
37261+
for (const operand of eachReactiveValueOperand(value)) {
37262+
operand.identifier.scope = fbtScope;
37263+
expandFbtScopeRange(fbtScope.range, operand.identifier.mutableRange);
37264+
fbtValues.add(operand.identifier.id);
37265+
}
3727237266
}
37273-
else if (Iterable_some(eachInstructionValueOperand(value), operand => macroValues.has(operand.identifier))) {
37274-
const macroOperands = [];
37275-
for (const operand of eachInstructionValueOperand(value)) {
37276-
if (macroValues.has(operand.identifier)) {
37277-
macroOperands.push(operand.identifier);
37267+
else if (fbtValues.has(lvalue.identifier.id)) {
37268+
const fbtScope = lvalue.identifier.scope;
37269+
if (fbtScope === null) {
37270+
return;
37271+
}
37272+
for (const operand of eachReactiveValueOperand(value)) {
37273+
if (operand.identifier.name !== null &&
37274+
operand.identifier.name.kind === 'named') {
37275+
continue;
3727837276
}
37277+
operand.identifier.scope = fbtScope;
37278+
expandFbtScopeRange(fbtScope.range, operand.identifier.mutableRange);
3727937279
}
37280-
macroValues.set(lvalue.identifier, macroOperands);
3728137280
}
3728237281
}
3728337282
}
3728437283
}
37285-
function mergeScopes(root, scope, macroValues, macroTagsCalls) {
37286-
const operands = macroValues.get(root);
37287-
if (operands == null) {
37288-
return;
37289-
}
37290-
for (const operand of operands) {
37291-
operand.scope = scope;
37292-
expandFbtScopeRange(scope.range, operand.mutableRange);
37293-
macroTagsCalls.add(operand.id);
37294-
mergeScopes(operand, scope, macroValues, macroTagsCalls);
37295-
}
37296-
}
3729737284
function matchesExactTag(s, tags) {
3729837285
return Array.from(tags).some(macro => typeof macro === 'string'
3729937286
? s === macro
@@ -37317,23 +37304,22 @@ function matchTagRoot(s, tags) {
3731737304
return null;
3731837305
}
3731937306
}
37320-
function isFbtCallExpression(macroTagsCalls, value) {
37307+
function isFbtCallExpression(fbtValues, value) {
3732137308
return ((value.kind === 'CallExpression' &&
37322-
macroTagsCalls.has(value.callee.identifier.id)) ||
37323-
(value.kind === 'MethodCall' &&
37324-
macroTagsCalls.has(value.property.identifier.id)));
37309+
fbtValues.has(value.callee.identifier.id)) ||
37310+
(value.kind === 'MethodCall' && fbtValues.has(value.property.identifier.id)));
3732537311
}
37326-
function isFbtJsxExpression(fbtMacroTags, macroTagsCalls, value) {
37312+
function isFbtJsxExpression(fbtMacroTags, fbtValues, value) {
3732737313
return (value.kind === 'JsxExpression' &&
3732837314
((value.tag.kind === 'Identifier' &&
37329-
macroTagsCalls.has(value.tag.identifier.id)) ||
37315+
fbtValues.has(value.tag.identifier.id)) ||
3733037316
(value.tag.kind === 'BuiltinTag' &&
3733137317
matchesExactTag(value.tag.name, fbtMacroTags))));
3733237318
}
37333-
function isFbtJsxChild(macroTagsCalls, lvalue, value) {
37319+
function isFbtJsxChild(fbtValues, lvalue, value) {
3733437320
return ((value.kind === 'JsxExpression' || value.kind === 'JsxFragment') &&
3733537321
lvalue !== null &&
37336-
macroTagsCalls.has(lvalue.identifier.id));
37322+
fbtValues.has(lvalue.identifier.id));
3733737323
}
3733837324
function expandFbtScopeRange(fbtRange, extendWith) {
3733937325
if (extendWith.start !== 0) {

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
85f415e33b95d65aaa29f92268b31d33060628ac
1+
903366b8b1ee4206020492c6e8140645c0cb563e
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
85f415e33b95d65aaa29f92268b31d33060628ac
1+
903366b8b1ee4206020492c6e8140645c0cb563e

compiled/facebook-www/React-dev.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ __DEV__ &&
14601460
exports.useTransition = function () {
14611461
return resolveDispatcher().useTransition();
14621462
};
1463-
exports.version = "19.3.0-www-classic-85f415e3-20251015";
1463+
exports.version = "19.3.0-www-classic-903366b8-20251015";
14641464
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14651465
"function" ===
14661466
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ __DEV__ &&
14601460
exports.useTransition = function () {
14611461
return resolveDispatcher().useTransition();
14621462
};
1463-
exports.version = "19.3.0-www-modern-85f415e3-20251015";
1463+
exports.version = "19.3.0-www-modern-903366b8-20251015";
14641464
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14651465
"function" ===
14661466
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,4 +606,4 @@ exports.useSyncExternalStore = function (
606606
exports.useTransition = function () {
607607
return ReactSharedInternals.H.useTransition();
608608
};
609-
exports.version = "19.3.0-www-classic-85f415e3-20251015";
609+
exports.version = "19.3.0-www-classic-903366b8-20251015";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,4 +606,4 @@ exports.useSyncExternalStore = function (
606606
exports.useTransition = function () {
607607
return ReactSharedInternals.H.useTransition();
608608
};
609-
exports.version = "19.3.0-www-modern-85f415e3-20251015";
609+
exports.version = "19.3.0-www-modern-903366b8-20251015";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ exports.useSyncExternalStore = function (
610610
exports.useTransition = function () {
611611
return ReactSharedInternals.H.useTransition();
612612
};
613-
exports.version = "19.3.0-www-classic-85f415e3-20251015";
613+
exports.version = "19.3.0-www-classic-903366b8-20251015";
614614
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
615615
"function" ===
616616
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ exports.useSyncExternalStore = function (
610610
exports.useTransition = function () {
611611
return ReactSharedInternals.H.useTransition();
612612
};
613-
exports.version = "19.3.0-www-modern-85f415e3-20251015";
613+
exports.version = "19.3.0-www-modern-903366b8-20251015";
614614
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
615615
"function" ===
616616
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20371,10 +20371,10 @@ __DEV__ &&
2037120371
(function () {
2037220372
var internals = {
2037320373
bundleType: 1,
20374-
version: "19.3.0-www-classic-85f415e3-20251015",
20374+
version: "19.3.0-www-classic-903366b8-20251015",
2037520375
rendererPackageName: "react-art",
2037620376
currentDispatcherRef: ReactSharedInternals,
20377-
reconcilerVersion: "19.3.0-www-classic-85f415e3-20251015"
20377+
reconcilerVersion: "19.3.0-www-classic-903366b8-20251015"
2037820378
};
2037920379
internals.overrideHookState = overrideHookState;
2038020380
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -20409,7 +20409,7 @@ __DEV__ &&
2040920409
exports.Shape = Shape;
2041020410
exports.Surface = Surface;
2041120411
exports.Text = Text;
20412-
exports.version = "19.3.0-www-classic-85f415e3-20251015";
20412+
exports.version = "19.3.0-www-classic-903366b8-20251015";
2041320413
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2041420414
"function" ===
2041520415
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)