Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0c35c01
feat: add _show prop to popover-button
yurtsever Oct 28, 2025
584740a
fix: reorder prop definition
yurtsever Oct 29, 2025
20fb60f
fix: tests
yurtsever Oct 29, 2025
b0aea25
fix: revert table changes
yurtsever Oct 29, 2025
ca0d0b4
update: change show prop to open
yurtsever Oct 29, 2025
8acf980
fix: revert open prop to show
yurtsever Oct 30, 2025
bbca1bb
fix: revert snapshot
yurtsever Oct 30, 2025
299a231
Update all snapshots$
yurtsever Oct 30, 2025
2320871
fix: validators and prop definitions
yurtsever Oct 31, 2025
80baa1b
merge branch
yurtsever Oct 31, 2025
f676770
fix: Adjust prop docs and show prop validation
yurtsever Oct 31, 2025
4618725
fix: update snapshot viewport
yurtsever Oct 31, 2025
13b93e8
fix: snapshot viewport
yurtsever Oct 31, 2025
5abd8cb
feat: add test case for default state
yurtsever Nov 3, 2025
c27ec59
fix: remove snapshot for windows
yurtsever Nov 3, 2025
4c3c400
feat: add missing test code
yurtsever Nov 3, 2025
8dfd7e7
Update all snapshots$
yurtsever Nov 3, 2025
29e636c
Merge branch 'release/3' into 8714-add-show-prop
yurtsever Nov 6, 2025
7bfc129
fix: handle popover after render
yurtsever Nov 6, 2025
6151652
Merge branch 'release/3' into 8714-add-show-prop
yurtsever Nov 6, 2025
dc534f8
Merge branch 'release/3' into 8714-add-show-prop
yurtsever Nov 7, 2025
2b2cecb
refactor: remove _show prop and related validation from KolPopoverBut…
deleonio Nov 12, 2025
8be41d0
Update all snapshots$
yurtsever Nov 12, 2025
8ad2f5d
fix: Remove tests for _show prop
yurtsever Nov 12, 2025
bc3ee56
Merge branch 'release/3' into 8714-add-show-prop
yurtsever Nov 13, 2025
0acdd36
Update all snapshots$
yurtsever Nov 13, 2025
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
31 changes: 29 additions & 2 deletions packages/components/src/components/popover-button/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,20 @@ export class KolPopoverButton implements PopoverButtonProps {
void this.refPopover?.hidePopover();
}

/**
* Show the popover programmatically by calling the native showPopover method.
*/
@Method()
// eslint-disable-next-line @typescript-eslint/require-await
public async showPopover() {
void this.refPopover?.showPopover();
}

/**
* Sets focus on the internal element.
*/
@Method()
public async kolFocus() {
// eslint-disable-next-line no-console
console.log('Focusing popover button', this.refButton);
await this.refButton?.kolFocus();
}

Expand Down Expand Up @@ -246,6 +253,11 @@ export class KolPopoverButton implements PopoverButtonProps {
*/
@Prop() public _shortKey?: ShortKeyPropType;

/**
* Defines whether the popover is shown.
*/
@Prop() public _show?: boolean = false;

/**
* Selector for synchronizing the value with another input element.
* @internal
Expand Down Expand Up @@ -277,11 +289,26 @@ export class KolPopoverButton implements PopoverButtonProps {
*/
@Prop() public _variant?: ButtonVariantPropType = 'normal';

@Watch('_show')
public validateShow(value?: boolean): void {
if (value && this.refPopover && !this.popoverOpen) {
this.refPopover.showPopover();
} else if (!value && this.refPopover && this.popoverOpen) {
this.refPopover.hidePopover();
}
}

@Watch('_popoverAlign')
public validatePopoverAlign(value?: PopoverAlignPropType): void {
validatePopoverAlign(this, value);
}

public componentDidLoad() {
if (this._show && this.refPopover) {
this.refPopover?.showPopover();
}
}

public componentWillLoad() {
this.validatePopoverAlign(this._popoverAlign);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,15 @@ test.describe('kol-popover-button', () => {
await button.click();
await expect(tooltip).not.toBeVisible();
});

test('should be open initially when the _show prop is set to true', async ({ page }) => {
await page.setContent(`
<kol-popover-button _show _label="Toggle popover">
Popover content
</kol-popover-button>
`);

const popover = page.getByTestId('popover-content');
await expect(popover).toBeVisible();
});
});
15 changes: 15 additions & 0 deletions packages/components/src/components/popover-button/shadow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ export class KolPopoverButton implements PopoverButtonProps {
void this.ref?.hidePopover();
}

/**
* Shows the popover programmatically by forwarding the call to the web component.
*/
@Method()
// eslint-disable-next-line @typescript-eslint/require-await
public async showPopover() {
void this.ref?.showPopover();
}

private catchRef = (ref?: HTMLKolPopoverButtonWcElement) => {
this.ref = ref;
};
Expand Down Expand Up @@ -69,6 +78,7 @@ export class KolPopoverButton implements PopoverButtonProps {
_label={this._label}
_name={this._name}
_on={this._on}
_show={this._show}
_popoverAlign={this._popoverAlign}
_shortKey={this._shortKey}
_syncValueBySelector={this._syncValueBySelector}
Expand Down Expand Up @@ -164,6 +174,11 @@ export class KolPopoverButton implements PopoverButtonProps {
*/
@Prop() public _shortKey?: ShortKeyPropType;

/**
* Defines whether the popover is shown.
*/
@Prop() public _show?: boolean;

/**
* Selector for synchronizing the value with another input element.
* @internal
Expand Down
5 changes: 4 additions & 1 deletion packages/components/src/schema/components/popover-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import type { PropLabelWithExpertSlot, PropPopoverAlign } from '../props';
import type { OptionalButtonProps, RequiredButtonProps } from './button';

export type RequiredPopoverButtonProps = RequiredButtonProps;
export type OptionalPopoverButtonProps = OptionalButtonProps & PropPopoverAlign;
export type OptionalPopoverButtonProps = OptionalButtonProps &
PropPopoverAlign & {
show: boolean;
};

export type RequiredPopoverButtonStates = PropLabelWithExpertSlot;
export type OptionalPopoverButtonStates = PropPopoverAlign;
Expand Down
14 changes: 2 additions & 12 deletions packages/samples/react/src/components/popover-button/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
import { KolHeading, KolPopoverButton, KolToolbar } from '@public-ui/react-v19';
import type { FC } from 'react';
import React, { useEffect } from 'react';
import React from 'react';
import { useToasterService } from '../../hooks/useToasterService';
import { SampleDescription } from '../SampleDescription';

export const PopoverButtonBasic: FC = () => {
const { dummyClickEventHandler } = useToasterService();
const buttonRef = React.useRef<HTMLKolPopoverButtonElement>(null);

useEffect(() => {
const run = async () => {
await buttonRef.current?.kolFocus();
if (buttonRef.current instanceof HTMLButtonElement) {
buttonRef.current.click();
}
};
run();
}, []);

const dummyEventHandler = {
onClick: dummyClickEventHandler,
};
Expand Down Expand Up @@ -49,7 +39,7 @@ export const PopoverButtonBasic: FC = () => {
</p>
</SampleDescription>
<div className="flex flex-col gap-4">
<KolPopoverButton _label={'Actions'} _variant="primary" _icons={{ right: 'codicon codicon-chevron-down' }} ref={buttonRef}>
<KolPopoverButton _show _label={'Actions'} _variant="primary" _icons={{ right: 'codicon codicon-chevron-down' }} ref={buttonRef}>
<KolToolbar _label="Action toolbar" _items={TOOLBAR_ITEMS} _orientation="vertical" />
</KolPopoverButton>
<KolPopoverButton _label="Help" _icons="codicon codicon-info" _popoverAlign="right" _tooltipAlign="bottom" _hideLabel>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading