Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(popover): set default Radix values #189

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/primitives/popover/src/popover-arrow.directive.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { NumberInput } from '@angular/cdk/coercion';
import { ConnectedOverlayPositionChange } from '@angular/cdk/overlay';
import {
AfterViewInit,
Expand All @@ -8,6 +9,7 @@ import {
forwardRef,
inject,
input,
numberAttribute,
Renderer2,
signal,
untracked
Expand Down Expand Up @@ -38,12 +40,12 @@ export class RdxPopoverArrowDirective implements AfterViewInit {
/**
* The width of the arrow in pixels.
*/
readonly width = input<number>(10);
readonly width = input<number, NumberInput>(10, { transform: numberAttribute });
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not necessary. I've never seen the usage of it before for such cases.
Angular inputs are typed, there is no point in having that transformer here :)


/**
* The height of the arrow in pixels.
*/
readonly height = input<number>(5);
readonly height = input<number, NumberInput>(5, { transform: numberAttribute });

/** @ignore */
readonly arrowSvgElement = computed<HTMLElement>(() => {
Expand Down
10 changes: 7 additions & 3 deletions packages/primitives/popover/src/popover-content.directive.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { BooleanInput, NumberInput } from '@angular/cdk/coercion';
import { CdkConnectedOverlay, Overlay } from '@angular/cdk/overlay';
import {
booleanAttribute,
computed,
DestroyRef,
Directive,
effect,
inject,
input,
numberAttribute,
OnInit,
output,
SimpleChange,
Expand Down Expand Up @@ -45,7 +48,7 @@ export class RdxPopoverContentDirective implements OnInit {
/**
* The distance in pixels from the trigger.
*/
readonly sideOffset = input<number | undefined>(void 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

it is intentional to have void 0 as a default value.

Copy link
Contributor

Choose a reason for hiding this comment

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

because the offsets are calculated as a fallback later on unless any number value is provided.
Angular will not allow to provide any other value that is of other than numer or undefined type.

Copy link
Contributor

Choose a reason for hiding this comment

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

obraz

the change will break that functionality

readonly sideOffset = input<number, NumberInput>(0, { transform: numberAttribute });

/**
* The preferred alignment against the trigger. May change when collisions occur.
Expand All @@ -54,12 +57,12 @@ export class RdxPopoverContentDirective implements OnInit {
/**
* An offset in pixels from the "start" or "end" alignment options.
*/
readonly alignOffset = input<number | undefined>(void 0);
readonly alignOffset = input<number, NumberInput>(0, { transform: numberAttribute });

/**
* Whether to add some alternate positions of the content.
*/
readonly disableAlternatePositions = input(false);
readonly disableAlternatePositions = input<boolean, BooleanInput>(false, { transform: booleanAttribute });
Copy link
Contributor

Choose a reason for hiding this comment

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

there is no point in having that transformer here - unnecessary code that brings no value imho


/** @ingore */
readonly positions = computed(() => {
Expand All @@ -83,6 +86,7 @@ export class RdxPopoverContentDirective implements OnInit {
* Alternate positions for better user experience along the X/Y axis (e.g. vertical/horizontal scrolling)
*/
const allPossibleConnectedPositions = getAllPossibleConnectedPositions();

allPossibleConnectedPositions.forEach((_, key) => {
const sideAndAlignArray = key.split('|');
if (
Expand Down
Loading