Skip to content

Migrate FtPrompt to the composition API#6551

Merged
FreeTubeBot merged 3 commits intoFreeTubeApp:developmentfrom
absidue:prompt-composition-api
Jan 14, 2025
Merged

Migrate FtPrompt to the composition API#6551
FreeTubeBot merged 3 commits intoFreeTubeApp:developmentfrom
absidue:prompt-composition-api

Conversation

@absidue
Copy link
Member

@absidue absidue commented Jan 11, 2025

Migrate FtPrompt to the composition API

Pull Request Type

  • Bugfix
  • Refactoring - Composition API migration

Description

This pull request migrates the FtPrompt component to the composition API. It also changes how the prompt label is handled.

Currently when a component specifies a custom body for the prompt it also has to take care of displaying the label with its own HTML and CSS, even if it doesn't change it from the default one. That also comes with an accessiblity issue, as the prompt has a aria-labelledby attribute but with the custom titles the ID isn't added, so the aria-labelledby points at an ID that doesn't exist.

To solve those issues I decided to move the label to its own slot (appropriately named "label"), that uses scoped slots to pass the ID for the label through to the parent component that is populating the slot. That means that components that only want to customise the body can now use the default label display (using the label prop) and components that want a custom label display such as the keyboard shortcuts one (needs to show the label and close button on the same line) or the changelog (uses an <h1> tag for the title instead of <h2>) can display a custom one and add the ID to it, so that it is correctly linked. The label prop was made optional so that components that customise its display don't have to duplicate the text into the prop.

Testing

Test various prompts in FreeTube such as the subscription export, search filters, changelog (edit the version in the package.json file to 0.22.0) and check that they work correctly (looks right, buttons work, keyboard interaction, clicking outside of it closes it).

Desktop

  • OS:
  • OS Version:
  • FreeTube version:

@github-actions github-actions bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label Jan 11, 2025
@FreeTubeBot FreeTubeBot enabled auto-merge (squash) January 11, 2025 17:48
@FreeTubeBot FreeTubeBot merged commit a20249a into FreeTubeApp:development Jan 14, 2025
5 checks passed
@github-actions github-actions bot removed the PR: waiting for review For PRs that are complete, tested, and ready for review label Jan 14, 2025
@absidue absidue deleted the prompt-composition-api branch January 14, 2025 15:35
SuperAKWA pushed a commit to SuperAKWA/FreeTube that referenced this pull request Jan 24, 2025
* Migrate FtPrompt to the composition API

* Show title for ft-share-button in the prompt on mobile

* Reduce diff
OothecaPickle pushed a commit to OothecaPickle/FreeTube that referenced this pull request Apr 29, 2025
* Migrate FtPrompt to the composition API

* Show title for ft-share-button in the prompt on mobile

* Reduce diff
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.

5 participants