Skip to content

Conversation

@maribethb
Copy link
Contributor

The basics

The details

Resolves

Fixes #9035

Proposed Changes

Checks that HTMLElement is defined before trying to use it

Reason for Changes

Dropdown fields should work in node

Test Coverage

Added a node test to make sure this change fixes the CI problems we saw in samples

Documentation

I logged a warning for the case that would hit if:

  1. Someone uses a FieldDropdown with HTMLElement options
  2. They use node, haven't supplied an implementation of HTMLElement, and call getText.

Honestly the chances anyone does this and doesn't run into a number of other issues is relatively small, but hopefully the warning message helps them out if so.

If someone is using node with just regular text options, they don't need to supply an implementation of HTMLElement and won't see the warning, so this doesn't affect the usual case (and before v12, the only case, as it wasn't possible to use element options).

Additional Information

@maribethb maribethb requested a review from a team as a code owner May 14, 2025 17:51
@maribethb maribethb requested a review from cpcallen May 14, 2025 17:51
@google-cla
Copy link

google-cla bot commented May 14, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@maribethb maribethb changed the base branch from develop to rc/v12.0.0 May 14, 2025 17:52
@maribethb maribethb changed the title Htmlelement fix: fieldDropdown.getText works in node May 14, 2025
@maribethb maribethb added the PR: fix Fixes a bug label May 14, 2025
@github-actions github-actions bot added PR: fix Fixes a bug and removed PR: fix Fixes a bug labels May 14, 2025
@maribethb
Copy link
Contributor Author

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

image

Copy link
Collaborator

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @maribethb! Approving to unblock, but had some thoughts (most of which likely don't need to happen now for v12).


assert.deepEqual(jsonAfter, json);
});
test('Dropdown getText works with no HTMLElement defined', function () {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to check: this test fails without the fix in place, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

"you're using HTMLElement dropdown options in node, ensure you're " +
'using jsdom-global or similar.',
);
return null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth verifying the console warning & null case in tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because in order to get here you'd have to pass something that is an HTMElement type but then don't have HTMLElement defined. It would be really annoying to set up in tests and is a scenario that is unlikely to happen at all. But I had to return null to satisfy the ts compiler and the warning helps figure out why that is, in the off chance it ever somehow does happen.

@maribethb maribethb merged commit 523dca9 into RaspberryPiFoundation:rc/v12.0.0 May 14, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: fix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

can't call FieldDropdown.getText in node

3 participants