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

Conversation

pimenovoleg
Copy link
Contributor

@pimenovoleg pimenovoleg commented Dec 12, 2024

Copy link

vercel bot commented Dec 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
blocks-showcase ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 12, 2024 5:40pm
primitives ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 12, 2024 5:40pm
radix-astro-doc ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 12, 2024 5:40pm
shadcn-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 12, 2024 5:40pm
taxonomy ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 12, 2024 5:40pm

@pimenovoleg
Copy link
Contributor Author

@pawel-twardziak look on this

@@ -47,7 +50,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

@@ -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 :)


/**
* 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

@@ -85,7 +88,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((value, key) => {
allPossibleConnectedPositions.forEach((_value, key) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

below, there is a piece of code to fix.

that:

const offsets: RdxSideAndAlignOffsets = {
  sideOffset: this.sideOffset() ?? (greatestDimensionFromTheArrow || DEFAULTS.offsets.side),
  alignOffset: this.alignOffset() ?? (greatestDimensionFromTheArrow || DEFAULTS.offsets.align)
};

should be this:

const offsets: RdxSideAndAlignOffsets = {
  sideOffset: this.sideOffset() ?? (greatestDimensionFromTheArrow || DEFAULTS.offsets.side),
  alignOffset: this.alignOffset()
};

it is because alignOffset should always be 0 by fefault. It is only the sideOffset that should get aligned to the arrow dimensions as fallback to void 0 or, if the arrow does not exist, to the default value then

Copy link
Contributor

Choose a reason for hiding this comment

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

I've fixed this there -> #192

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.

2 participants