Skip to content

fix(ui): support defaultValue in showFontPicker app environment#3118

Open
SusTechStitch wants to merge 1 commit into
HeyPuter:mainfrom
SusTechStitch:fix-show-font-picker-default-value
Open

fix(ui): support defaultValue in showFontPicker app environment#3118
SusTechStitch wants to merge 1 commit into
HeyPuter:mainfrom
SusTechStitch:fix-show-font-picker-default-value

Conversation

@SusTechStitch
Copy link
Copy Markdown

Fixes #2896.

Summary

This PR makes puter.ui.showFontPicker handle default font options consistently in the Puter app environment.

Changes:

  • Normalize string shorthand, defaultFont, defaultValue, and legacy default before sending options to the app environment
  • Support defaultValue, defaultFont, and default in UIWindowFontPicker
  • Fix scrolling to the active default font by avoiding shadowing the global window
  • Add defaultValue to FontPickerOptions

Testing

  • git diff --check
  • node --check src/puter-js/src/modules/UI.js
  • node --check src/gui/src/UI/UIWindowFontPicker.js
  • npm start

Manually tested in the Puter app environment:

await puter.ui.showFontPicker("Georgia");
await puter.ui.showFontPicker({ defaultFont: "Georgia" });
await puter.ui.showFontPicker({ defaultValue: "Georgia" });

All three calls open the font picker with Georgia preselected.

Copilot AI review requested due to automatic review settings May 15, 2026 16:20
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the puter.ui.showFontPicker SDK API and the app-environment font picker window to consistently honor a “default font” provided via string shorthand, defaultFont, defaultValue, or legacy default (Fixes #2896).

Changes:

  • Normalize showFontPicker inputs in the SDK (string shorthand + multiple default-* option keys) before posting to the app environment.
  • Update UIWindowFontPicker to read defaultValue/defaultFont/default and to scroll to the active default font without shadowing the global window.
  • Extend TypeScript types with FontPickerOptions.defaultValue.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/puter-js/types/modules/ui.d.ts Adds defaultValue to FontPickerOptions for typed support.
src/puter-js/src/modules/UI.js Normalizes font picker options (including string shorthand) before app messaging and keeps web-component fallback consistent.
src/gui/src/UI/UIWindowFontPicker.js Supports defaultValue/defaultFont/legacy default and fixes default-item scroll behavior in the app UI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +96 to +98
const font_list = $(elWindow).find('.font-list').get(0);
if ( window.scrollParentToChild ) {
window.scrollParentToChild(font_list, active_font.get(0));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for defaultValue option for puter.ui.showFontPicker in puter app environment

3 participants